6.10.3-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 506/809 pinctrl: renesas: r8a779g0: Fix TCLK suffixes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit bfd2428f3a80647af681df4793e473258aa755da ]
The Pin Multiplex attachment in Rev.1.10 of the R-Car V4H Series Hardware User's Manual still has two alternate pins named both TCLK3 and TCLK4. To differentiate, the pin control driver uses "TCLK[34]" and "TCLK[34]_X". In addition, there are alternate pins without suffix, and with an "_A" or "_B" suffix.
Increase uniformity by adopting R-Car V4M naming:
- Rename "TCLK2_B" to "TCLK2_C",
- Rename "TCLK[12]_A" to "TCLK[12]_B",
- Rename "TCLK[12]" to "TCLK[12]_A",
- Rename "TCLK[34]_A" to "TCLK[34]_C",
- Rename "TCLK[34]_X" to "TCLK[34]_A",
- Rename "TCLK[34]" to "TCLK[34]_B".
--- drivers/pinctrl/renesas/pfc-r8a779g0.c | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/pinctrl/renesas/pfc-r8a779g0.c +22 -22
@@ -275,7 +275,7 @@/* SR0 */ /* IP0SR0 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */ -#define IP0SR0_3_0 F_(0, 0) FM(ERROROUTC_N_B) FM(TCLK2_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP0SR0_3_0 F_(0, 0) FM(ERROROUTC_N_B) FM(TCLK2_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR0_7_4 F_(0, 0) FM(MSIOF3_SS1) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR0_11_8 F_(0, 0) FM(MSIOF3_SS2) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR0_15_12 FM(IRQ3_A) FM(MSIOF3_SCK) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)
@@ -290,7 +290,7 @@#define IP1SR0_11_8 FM(MSIOF5_TXD) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR0_15_12 FM(MSIOF5_SCK) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR0_19_16 FM(MSIOF5_RXD) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP1SR0_23_20 FM(MSIOF2_SS2) FM(TCLK1) FM(IRQ2_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR0_23_20 FM(MSIOF2_SS2) FM(TCLK1_A) FM(IRQ2_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR0_27_24 FM(MSIOF2_SS1) FM(HTX1_A) FM(TX1_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR0_31_28 FM(MSIOF2_SYNC) FM(HRX1_A) FM(RX1_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)
@@ -323,12 +323,12 @@/* IP2SR1 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */ #define IP2SR1_3_0 FM(HRX0) FM(RX0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP2SR1_7_4 FM(SCIF_CLK) FM(IRQ4_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP2SR1_11_8 FM(SSI_SCK) FM(TCLK3) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP2SR1_15_12 FM(SSI_WS) FM(TCLK4) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP2SR1_11_8 FM(SSI_SCK) FM(TCLK3_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP2SR1_15_12 FM(SSI_WS) FM(TCLK4_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP2SR1_19_16 FM(SSI_SD) FM(IRQ0_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP2SR1_23_20 FM(AUDIO_CLKOUT) FM(IRQ1_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP2SR1_27_24 FM(AUDIO_CLKIN) FM(PWM3_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP2SR1_31_28 F_(0, 0) FM(TCLK2) FM(MSIOF4_SS1) FM(IRQ3_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP2SR1_31_28 F_(0, 0) FM(TCLK2_A) FM(MSIOF4_SS1) FM(IRQ3_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)/* IP3SR1 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */ #define IP3SR1_3_0 FM(HRX3_A) FM(SCK3_A) FM(MSIOF4_SS2) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)
@@ -346,15 +346,15 @@#define IP0SR2_19_16 FM(RXDB_EXTFXR) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR2_23_20 FM(FXR_TXENB_N_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR2_27_24 FM(FXR_TXDB) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP0SR2_31_28 FM(TPU0TO1) FM(CANFD6_TX) F_(0, 0) FM(TCLK2_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP0SR2_31_28 FM(TPU0TO1) FM(CANFD6_TX) F_(0, 0) FM(TCLK2_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)/* IP1SR2 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */ -#define IP1SR2_3_0 FM(TPU0TO0) FM(CANFD6_RX) F_(0, 0) FM(TCLK1_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR2_3_0 FM(TPU0TO0) FM(CANFD6_RX) F_(0, 0) FM(TCLK1_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_7_4 FM(CAN_CLK) FM(FXR_TXENA_N_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_11_8 FM(CANFD0_TX) FM(FXR_TXENB_N_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_15_12 FM(CANFD0_RX) FM(STPWT_EXTFXR) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP1SR2_19_16 FM(CANFD2_TX) FM(TPU0TO2) F_(0, 0) FM(TCLK3_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP1SR2_23_20 FM(CANFD2_RX) FM(TPU0TO3) FM(PWM1_B) FM(TCLK4_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR2_19_16 FM(CANFD2_TX) FM(TPU0TO2) F_(0, 0) FM(TCLK3_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR2_23_20 FM(CANFD2_RX) FM(TPU0TO3) FM(PWM1_B) FM(TCLK4_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_27_24 FM(CANFD3_TX) F_(0, 0) FM(PWM2) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_31_28 FM(CANFD3_RX) F_(0, 0) FM(PWM3_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)
@@ -381,8 +381,8 @@#define IP1SR3_11_8 FM(MMC_SD_CMD) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR3_15_12 FM(SD_CD) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR3_19_16 FM(SD_WP) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP1SR3_23_20 FM(IPC_CLKIN) FM(IPC_CLKEN_IN) FM(PWM1_A) FM(TCLK3_X) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP1SR3_27_24 FM(IPC_CLKOUT) FM(IPC_CLKEN_OUT) FM(ERROROUTC_N_A) FM(TCLK4_X) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR3_23_20 FM(IPC_CLKIN) FM(IPC_CLKEN_IN) FM(PWM1_A) FM(TCLK3_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR3_27_24 FM(IPC_CLKOUT) FM(IPC_CLKEN_OUT) FM(ERROROUTC_N_A) FM(TCLK4_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR3_31_28 FM(QSPI0_SSL) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)/* IP2SR3 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */
@@ -718,7 +718,7 @@ static const u16 pinmux_data[] = {/* IP0SR0 */ PINMUX_IPSR_GPSR (IP0SR0_3_0 ,ERROROUTC_N_B ), -PINMUX_IPSR_GPSR (IP0SR0_3_0 ,TCLK2_A ), +PINMUX_IPSR_GPSR (IP0SR0_3_0 ,TCLK2_B ), PINMUX_IPSR_GPSR(IP0SR0_7_4, MSIOF3_SS1),
@@ -750,7 +750,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP1SR0_19_16 ,MSIOF5_RXD ),PINMUX_IPSR_GPSR (IP1SR0_23_20 ,MSIOF2_SS2 ), -PINMUX_IPSR_GPSR (IP1SR0_23_20 ,TCLK1 ), +PINMUX_IPSR_GPSR (IP1SR0_23_20 ,TCLK1_A ),PINMUX_IPSR_GPSR (IP1SR0_23_20 ,IRQ2_B ), PINMUX_IPSR_GPSR(IP1SR0_27_24, MSIOF2_SS1),
@@ -845,10 +845,10 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP2SR1_7_4 ,IRQ4_A ),PINMUX_IPSR_GPSR (IP2SR1_11_8 ,SSI_SCK ), -PINMUX_IPSR_GPSR (IP2SR1_11_8 ,TCLK3 ), +PINMUX_IPSR_GPSR (IP2SR1_11_8 ,TCLK3_B ),PINMUX_IPSR_GPSR (IP2SR1_15_12 ,SSI_WS ), -PINMUX_IPSR_GPSR (IP2SR1_15_12 ,TCLK4 ), +PINMUX_IPSR_GPSR (IP2SR1_15_12 ,TCLK4_B ),PINMUX_IPSR_GPSR (IP2SR1_19_16 ,SSI_SD ), PINMUX_IPSR_GPSR(IP2SR1_19_16, IRQ0_B),
@@ -859,7 +859,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP2SR1_27_24 ,AUDIO_CLKIN ),PINMUX_IPSR_GPSR (IP2SR1_27_24 ,PWM3_A ), -PINMUX_IPSR_GPSR (IP2SR1_31_28 ,TCLK2 ), +PINMUX_IPSR_GPSR (IP2SR1_31_28 ,TCLK2_A ),PINMUX_IPSR_GPSR (IP2SR1_31_28 ,MSIOF4_SS1 ), PINMUX_IPSR_GPSR(IP2SR1_31_28, IRQ3_B),
@@ -911,12 +911,12 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP0SR2_31_28 ,TPU0TO1 ),PINMUX_IPSR_GPSR (IP0SR2_31_28 ,CANFD6_TX ), -PINMUX_IPSR_GPSR (IP0SR2_31_28 ,TCLK2_B ), +PINMUX_IPSR_GPSR (IP0SR2_31_28 ,TCLK2_C ),/* IP1SR2 */ PINMUX_IPSR_GPSR (IP1SR2_3_0 ,TPU0TO0 ),PINMUX_IPSR_GPSR (IP1SR2_3_0 ,CANFD6_RX ), -PINMUX_IPSR_GPSR (IP1SR2_3_0 ,TCLK1_A ), +PINMUX_IPSR_GPSR (IP1SR2_3_0 ,TCLK1_B ),PINMUX_IPSR_GPSR (IP1SR2_7_4 ,CAN_CLK ), PINMUX_IPSR_GPSR(IP1SR2_7_4, FXR_TXENA_N_B),
@@ -929,12 +929,12 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP1SR2_19_16 ,CANFD2_TX ),PINMUX_IPSR_GPSR (IP1SR2_19_16 ,TPU0TO2 ), -PINMUX_IPSR_GPSR (IP1SR2_19_16 ,TCLK3_A ), +PINMUX_IPSR_GPSR (IP1SR2_19_16 ,TCLK3_C ),PINMUX_IPSR_GPSR (IP1SR2_23_20 ,CANFD2_RX ),PINMUX_IPSR_GPSR (IP1SR2_23_20 ,TPU0TO3 ),PINMUX_IPSR_GPSR (IP1SR2_23_20 ,PWM1_B ), -PINMUX_IPSR_GPSR (IP1SR2_23_20 ,TCLK4_A ), +PINMUX_IPSR_GPSR (IP1SR2_23_20 ,TCLK4_C ),PINMUX_IPSR_GPSR (IP1SR2_27_24 ,CANFD3_TX ), PINMUX_IPSR_GPSR(IP1SR2_27_24, PWM2),
@@ -979,12 +979,12 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP1SR3_23_20 ,IPC_CLKIN ),PINMUX_IPSR_GPSR (IP1SR3_23_20 ,IPC_CLKEN_IN ),PINMUX_IPSR_GPSR (IP1SR3_23_20 ,PWM1_A ), -PINMUX_IPSR_GPSR (IP1SR3_23_20 ,TCLK3_X ), +PINMUX_IPSR_GPSR (IP1SR3_23_20 ,TCLK3_A ),PINMUX_IPSR_GPSR (IP1SR3_27_24 ,IPC_CLKOUT ),PINMUX_IPSR_GPSR (IP1SR3_27_24 ,IPC_CLKEN_OUT ),PINMUX_IPSR_GPSR (IP1SR3_27_24 ,ERROROUTC_N_A ), -PINMUX_IPSR_GPSR (IP1SR3_27_24 ,TCLK4_X ), +PINMUX_IPSR_GPSR (IP1SR3_27_24 ,TCLK4_A ), PINMUX_IPSR_GPSR(IP1SR3_31_28, QSPI0_SSL),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 507/809 pinctrl: renesas: r8a779g0: Fix TPU suffixes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 3d144ef10a448f89065dcff39c40d90ac18e035e ]
The Timer Pulse Unit channels have two alternate pin groups:
"tpu_to[0-3]" and "tpu_to[0-3]_a".
Increase uniformity by adopting R-Car V4M naming:
- Rename "tpu_to[0-3]_a" to "tpu_to[0-3]_b",
- Rename "tpu_to[0-3]" to "tpu_to[0-3]_a",
--- drivers/pinctrl/renesas/pfc-r8a779g0.c | 128 ++++++++++++------------- 1 file changed, 63 insertions(+), 65 deletions(-)
drivers/pinctrl/renesas/pfc-r8a779g0.c +63 -65
@@ -119,8 +119,8 @@#define GPSR2_11 F_(CANFD0_RX, IP1SR2_15_12)#define GPSR2_10 F_(CANFD0_TX, IP1SR2_11_8)#define GPSR2_9 F_(CAN_CLK, IP1SR2_7_4) -#define GPSR2_8 F_(TPU0TO0, IP1SR2_3_0) -#define GPSR2_7 F_(TPU0TO1, IP0SR2_31_28) +#define GPSR2_8 F_(TPU0TO0_A, IP1SR2_3_0) +#define GPSR2_7 F_(TPU0TO1_A, IP0SR2_31_28)#define GPSR2_6 F_(FXR_TXDB, IP0SR2_27_24)#define GPSR2_5 F_(FXR_TXENB_N_A, IP0SR2_23_20)#define GPSR2_4 F_(RXDB_EXTFXR, IP0SR2_19_16)
@@ -332,29 +332,29 @@/* IP3SR1 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */ #define IP3SR1_3_0 FM(HRX3_A) FM(SCK3_A) FM(MSIOF4_SS2) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP3SR1_7_4 FM(HSCK3_A) FM(CTS3_N_A) FM(MSIOF4_SCK) FM(TPU0TO0_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP3SR1_11_8 FM(HRTS3_N_A) FM(RTS3_N_A) FM(MSIOF4_TXD) FM(TPU0TO1_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP3SR1_7_4 FM(HSCK3_A) FM(CTS3_N_A) FM(MSIOF4_SCK) FM(TPU0TO0_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP3SR1_11_8 FM(HRTS3_N_A) FM(RTS3_N_A) FM(MSIOF4_TXD) FM(TPU0TO1_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP3SR1_15_12 FM(HCTS3_N_A) FM(RX3_A) FM(MSIOF4_RXD) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP3SR1_19_16 FM(HTX3_A) FM(TX3_A) FM(MSIOF4_SYNC) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)/* SR2 */ /* IP0SR2 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */ -#define IP0SR2_3_0 FM(FXR_TXDA) FM(CANFD1_TX) FM(TPU0TO2_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP0SR2_7_4 FM(FXR_TXENA_N_A) FM(CANFD1_RX) FM(TPU0TO3_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP0SR2_3_0 FM(FXR_TXDA) FM(CANFD1_TX) FM(TPU0TO2_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP0SR2_7_4 FM(FXR_TXENA_N_A) FM(CANFD1_RX) FM(TPU0TO3_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR2_11_8 FM(RXDA_EXTFXR) FM(CANFD5_TX_A) FM(IRQ5) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR2_15_12 FM(CLK_EXTFXR) FM(CANFD5_RX_A) FM(IRQ4_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR2_19_16 FM(RXDB_EXTFXR) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR2_23_20 FM(FXR_TXENB_N_A) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP0SR2_27_24 FM(FXR_TXDB) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP0SR2_31_28 FM(TPU0TO1) FM(CANFD6_TX) F_(0, 0) FM(TCLK2_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP0SR2_31_28 FM(TPU0TO1_A) FM(CANFD6_TX) F_(0, 0) FM(TCLK2_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)/* IP1SR2 */ /* 0 */ /* 1 */ /* 2 */ /* 3 4 5 6 7 8 9 A B C D E F */ -#define IP1SR2_3_0 FM(TPU0TO0) FM(CANFD6_RX) F_(0, 0) FM(TCLK1_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR2_3_0 FM(TPU0TO0_A) FM(CANFD6_RX) F_(0, 0) FM(TCLK1_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_7_4 FM(CAN_CLK) FM(FXR_TXENA_N_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_11_8 FM(CANFD0_TX) FM(FXR_TXENB_N_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_15_12 FM(CANFD0_RX) FM(STPWT_EXTFXR) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP1SR2_19_16 FM(CANFD2_TX) FM(TPU0TO2) F_(0, 0) FM(TCLK3_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) -#define IP1SR2_23_20 FM(CANFD2_RX) FM(TPU0TO3) FM(PWM1_B) FM(TCLK4_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR2_19_16 FM(CANFD2_TX) FM(TPU0TO2_A) F_(0, 0) FM(TCLK3_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) +#define IP1SR2_23_20 FM(CANFD2_RX) FM(TPU0TO3_A) FM(PWM1_B) FM(TCLK4_C) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_27_24 FM(CANFD3_TX) F_(0, 0) FM(PWM2) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)#define IP1SR2_31_28 FM(CANFD3_RX) F_(0, 0) FM(PWM3_B) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0) F_(0, 0)
@@ -871,12 +871,12 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP3SR1_7_4 ,HSCK3_A ),PINMUX_IPSR_GPSR (IP3SR1_7_4 ,CTS3_N_A ),PINMUX_IPSR_GPSR (IP3SR1_7_4 ,MSIOF4_SCK ), -PINMUX_IPSR_GPSR (IP3SR1_7_4 ,TPU0TO0_A ), +PINMUX_IPSR_GPSR (IP3SR1_7_4 ,TPU0TO0_B ),PINMUX_IPSR_GPSR (IP3SR1_11_8 ,HRTS3_N_A ),PINMUX_IPSR_GPSR (IP3SR1_11_8 ,RTS3_N_A ),PINMUX_IPSR_GPSR (IP3SR1_11_8 ,MSIOF4_TXD ), -PINMUX_IPSR_GPSR (IP3SR1_11_8 ,TPU0TO1_A ), +PINMUX_IPSR_GPSR (IP3SR1_11_8 ,TPU0TO1_B ),PINMUX_IPSR_GPSR (IP3SR1_15_12 ,HCTS3_N_A ), PINMUX_IPSR_GPSR(IP3SR1_15_12, RX3_A),
@@ -889,11 +889,11 @@ static const u16 pinmux_data[] = {/* IP0SR2 */ PINMUX_IPSR_GPSR (IP0SR2_3_0 ,FXR_TXDA ),PINMUX_IPSR_GPSR (IP0SR2_3_0 ,CANFD1_TX ), -PINMUX_IPSR_GPSR (IP0SR2_3_0 ,TPU0TO2_A ), +PINMUX_IPSR_GPSR (IP0SR2_3_0 ,TPU0TO2_B ),PINMUX_IPSR_GPSR (IP0SR2_7_4 ,FXR_TXENA_N_A ),PINMUX_IPSR_GPSR (IP0SR2_7_4 ,CANFD1_RX ), -PINMUX_IPSR_GPSR (IP0SR2_7_4 ,TPU0TO3_A ), +PINMUX_IPSR_GPSR (IP0SR2_7_4 ,TPU0TO3_B ),PINMUX_IPSR_GPSR (IP0SR2_11_8 ,RXDA_EXTFXR ), PINMUX_IPSR_GPSR(IP0SR2_11_8, CANFD5_TX_A),
@@ -909,12 +909,12 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP0SR2_27_24 ,FXR_TXDB ), -PINMUX_IPSR_GPSR (IP0SR2_31_28 ,TPU0TO1 ), +PINMUX_IPSR_GPSR (IP0SR2_31_28 ,TPU0TO1_A ),PINMUX_IPSR_GPSR (IP0SR2_31_28 ,CANFD6_TX ),PINMUX_IPSR_GPSR (IP0SR2_31_28 ,TCLK2_C ),/* IP1SR2 */ -PINMUX_IPSR_GPSR (IP1SR2_3_0 ,TPU0TO0 ), +PINMUX_IPSR_GPSR (IP1SR2_3_0 ,TPU0TO0_A ),PINMUX_IPSR_GPSR (IP1SR2_3_0 ,CANFD6_RX ), PINMUX_IPSR_GPSR(IP1SR2_3_0, TCLK1_B),
@@ -928,11 +928,11 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP1SR2_15_12 ,STPWT_EXTFXR ),PINMUX_IPSR_GPSR (IP1SR2_19_16 ,CANFD2_TX ), -PINMUX_IPSR_GPSR (IP1SR2_19_16 ,TPU0TO2 ), +PINMUX_IPSR_GPSR (IP1SR2_19_16 ,TPU0TO2_A ),PINMUX_IPSR_GPSR (IP1SR2_19_16 ,TCLK3_C ),PINMUX_IPSR_GPSR (IP1SR2_23_20 ,CANFD2_RX ), -PINMUX_IPSR_GPSR (IP1SR2_23_20 ,TPU0TO3 ), +PINMUX_IPSR_GPSR (IP1SR2_23_20 ,TPU0TO3_A ),PINMUX_IPSR_GPSR (IP1SR2_23_20 ,PWM1_B ), PINMUX_IPSR_GPSR(IP1SR2_23_20, TCLK4_C),
@@ -2403,64 +2403,63 @@ static const unsigned int ssi_ctrl_mux[] = { SSI_SCK_MARK, SSI_WS_MARK, }; -/* - TPU ------------------------------------------------------------------- */ -static const unsigned int tpu_to0_pins[] = { -/* TPU0TO0 */ +/* - TPU -------------------------------------------------------------------- */ +static const unsigned int tpu_to0_a_pins[] = { +/* TPU0TO0_A */ RCAR_GP_PIN (2 ,8 ), }; -static const unsigned int tpu_to0_mux[] = { -TPU0TO0_MARK , +static const unsigned int tpu_to0_a_mux[] = { +TPU0TO0_A_MARK , }; -static const unsigned int tpu_to1_pins[] = { -/* TPU0TO1 */ +static const unsigned int tpu_to1_a_pins[] = { +/* TPU0TO1_A */ RCAR_GP_PIN (2 ,7 ), }; -static const unsigned int tpu_to1_mux[] = { -TPU0TO1_MARK , +static const unsigned int tpu_to1_a_mux[] = { +TPU0TO1_A_MARK , }; -static const unsigned int tpu_to2_pins[] = { -/* TPU0TO2 */ +static const unsigned int tpu_to2_a_pins[] = { +/* TPU0TO2_A */ RCAR_GP_PIN (2 ,12 ), }; -static const unsigned int tpu_to2_mux[] = { -TPU0TO2_MARK , +static const unsigned int tpu_to2_a_mux[] = { +TPU0TO2_A_MARK , }; -static const unsigned int tpu_to3_pins[] = { -/* TPU0TO3 */ +static const unsigned int tpu_to3_a_pins[] = { +/* TPU0TO3_A */ RCAR_GP_PIN (2 ,13 ), }; -static const unsigned int tpu_to3_mux[] = { -TPU0TO3_MARK , +static const unsigned int tpu_to3_a_mux[] = { +TPU0TO3_A_MARK , }; -/* - TPU_A ------------------------------------------------------------------- */ -static const unsigned int tpu_to0_a_pins[] = { -/* TPU0TO0_A */ +static const unsigned int tpu_to0_b_pins[] = { +/* TPU0TO0_B */ RCAR_GP_PIN (1 ,25 ), }; -static const unsigned int tpu_to0_a_mux[] = { -TPU0TO0_A_MARK , +static const unsigned int tpu_to0_b_mux[] = { +TPU0TO0_B_MARK , }; -static const unsigned int tpu_to1_a_pins[] = { -/* TPU0TO1_A */ +static const unsigned int tpu_to1_b_pins[] = { +/* TPU0TO1_B */ RCAR_GP_PIN (1 ,26 ), }; -static const unsigned int tpu_to1_a_mux[] = { -TPU0TO1_A_MARK , +static const unsigned int tpu_to1_b_mux[] = { +TPU0TO1_B_MARK , }; -static const unsigned int tpu_to2_a_pins[] = { -/* TPU0TO2_A */ +static const unsigned int tpu_to2_b_pins[] = { +/* TPU0TO2_B */ RCAR_GP_PIN (2 ,0 ), }; -static const unsigned int tpu_to2_a_mux[] = { -TPU0TO2_A_MARK , +static const unsigned int tpu_to2_b_mux[] = { +TPU0TO2_B_MARK , }; -static const unsigned int tpu_to3_a_pins[] = { -/* TPU0TO3_A */ +static const unsigned int tpu_to3_b_pins[] = { +/* TPU0TO3_B */ RCAR_GP_PIN (2 ,1 ), }; -static const unsigned int tpu_to3_a_mux[] = { -TPU0TO3_A_MARK , +static const unsigned int tpu_to3_b_mux[] = { +TPU0TO3_B_MARK , };/* - TSN0 ------------------------------------------------ */
@@ -2702,14 +2701,14 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {SH_PFC_PIN_GROUP (ssi_data),SH_PFC_PIN_GROUP (ssi_ctrl), -SH_PFC_PIN_GROUP (tpu_to0),/* suffix might be updated */ -SH_PFC_PIN_GROUP (tpu_to0_a),/* suffix might be updated */ -SH_PFC_PIN_GROUP (tpu_to1),/* suffix might be updated */ -SH_PFC_PIN_GROUP (tpu_to1_a),/* suffix might be updated */ -SH_PFC_PIN_GROUP (tpu_to2),/* suffix might be updated */ -SH_PFC_PIN_GROUP (tpu_to2_a),/* suffix might be updated */ -SH_PFC_PIN_GROUP (tpu_to3),/* suffix might be updated */ -SH_PFC_PIN_GROUP (tpu_to3_a),/* suffix might be updated */ +SH_PFC_PIN_GROUP (tpu_to0_a), +SH_PFC_PIN_GROUP (tpu_to0_b), +SH_PFC_PIN_GROUP (tpu_to1_a), +SH_PFC_PIN_GROUP (tpu_to1_b), +SH_PFC_PIN_GROUP (tpu_to2_a), +SH_PFC_PIN_GROUP (tpu_to2_b), +SH_PFC_PIN_GROUP (tpu_to3_a), +SH_PFC_PIN_GROUP (tpu_to3_b),SH_PFC_PIN_GROUP (tsn0_link), SH_PFC_PIN_GROUP(tsn0_phy_int),
@@ -3020,15 +3019,14 @@ static const char * const ssi_groups[] = { };static const char *const tpu_groups[] = { -/* suffix might be updated */ -"tpu_to0" ,"tpu_to0_a" , -"tpu_to1" , +"tpu_to0_b" ,"tpu_to1_a" , -"tpu_to2" , +"tpu_to1_b" ,"tpu_to2_a" , -"tpu_to3" , +"tpu_to2_b" ,"tpu_to3_a" , +"tpu_to3_b" , };static const char *const tsn0_groups[] = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 508/809 fs/proc/task_mmu: indicate PM_FILE for PMD-mapped file THP
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit 3f9f022e975d930709848a86a1c79775b0585202 ]
Patch series "fs/proc: move page_mapcount() to fs/proc/internal.h".
With all other page_mapcount() users in the tree gone, move page_mapcount() to fs/proc/internal.h, rename it and extend the documentation to prevent future (ab)use.
... of course, I find some issues while working on that code that I sort first ;)
We'll now only end up calling page_mapcount() [now folio_precise_page_mapcount()] on pages mapped via present page table entries. Except for /proc/kpagecount, that still does questionable things, but we'll leave that legacy interface as is for now.
Did a quick sanity check. Likely we would want some better selfestest for /proc/$/pagemap + smaps. I'll see if I can find some time to write some more.
This patch (of 6):
Looks like we never taught pagemap_pmd_range() about the existence of PMD-mapped file THPs. Seems to date back to the times when we first added support for non-anon THPs in the form of shmem THP.
--- fs/proc/task_mmu.c | 2 ++ 1 file changed, 2 insertions(+)
fs/proc/task_mmu.c +2 -0
@@ -1525,6 +1525,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, }#endif +if (page && !PageAnon (page)) + flags |=PM_FILE ;if (page && !migration &&page_mapcount (page) ==1 ) flags |=PM_MMAP_EXCLUSIVE ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 509/809 fs/proc/task_mmu: dont indicate PM_MMAP_EXCLUSIVE without PM_PRESENT
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit da7f31ed0f4df8f61e8195e527aa83dd54896ba3 ]
Relying on the mapcount for non-present PTEs that reference pages doesn't make any sense: they are not accounted in the mapcount, so page_mapcount() == 1 won't return the result we actually want to know.
While we don't check the mapcount for migration entries already, we could end up checking it for swap, hwpoison, device exclusive, ... entries, which we really shouldn't.
There is one exception: device private entries, which we consider fake-present (e.g., incremented the mapcount). But we won't care about that for now for PM_MMAP_EXCLUSIVE, because indicating PM_SWAP for them although they are fake-present already sounds suspiciously wrong.
Let's never indicate PM_MMAP_EXCLUSIVE without PM_PRESENT.
Stable-dep-of: 2c1f057e5be6 ("fs/proc/task_mmu: properly detect PM_MMAP_EXCLUSIVE per page of PMD-mapped THPs")
--- fs/proc/task_mmu.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/proc/task_mmu.c +2 -6
@@ -1418,7 +1418,6 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm, {u64 frame =0 , flags =0 ;struct page *page =NULL ; -bool migration = false;if (pte_present (pte)) {if (pm->show_pfn)
@@ -1450,7 +1449,6 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm, (offset <<MAX_SWAPFILES_SHIFT ); } flags |=PM_SWAP ; - migration =is_migration_entry (entry);if (is_pfn_swap_entry (entry)) page =pfn_swap_entry_to_page (entry);if (pte_marker_entry_uffd_wp (entry))
@@ -1459,7 +1457,7 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,if (page && !PageAnon (page)) flags |=PM_FILE ; -if (page && !migration &&page_mapcount (page) ==1 ) +if (page && (flags &PM_PRESENT ) &&page_mapcount (page) ==1 ) flags |=PM_MMAP_EXCLUSIVE ;if (vma->vm_flags &VM_SOFTDIRTY ) flags |=PM_SOFT_DIRTY ;
@@ -1476,7 +1474,6 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,pte_t *pte, *orig_pte;int err =0 ;#ifdef CONFIG_TRANSPARENT_HUGEPAGE -bool migration = false; ptl =pmd_trans_huge_lock (pmdp, vma);if (ptl) {
@@ -1520,14 +1517,13 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,if (pmd_swp_uffd_wp (pmd)) flags |=PM_UFFD_WP ;VM_BUG_ON (!is_pmd_migration_entry (pmd)); - migration =is_migration_entry (entry); page = pfn_swap_entry_to_page(entry); }#endif if (page && !PageAnon (page)) flags |=PM_FILE ; -if (page && !migration &&page_mapcount (page) ==1 ) +if (page && (flags &PM_PRESENT ) &&page_mapcount (page) ==1 ) flags |=PM_MMAP_EXCLUSIVE ;for (; addr != end; addr +=PAGE_SIZE ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 510/809 fs/proc/task_mmu: properly detect PM_MMAP_EXCLUSIVE per page of PMD-mapped THPs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit 2c1f057e5be63e890f2dd89e4c25ab5eef084a91 ]
We added PM_MMAP_EXCLUSIVE in 2015 via commit 77bb499bb60f ("pagemap: add mmap-exclusive bit for marking pages mapped only here"), when THPs could not be partially mapped and page_mapcount() returned something that was true for all pages of the THP.
In 2016, we added support for partially mapping THPs via commit 53f9263baba6 ("mm: rework mapcount accounting to enable 4k mapping of THPs") but missed to determine PM_MMAP_EXCLUSIVE as well per page.
Checking page_mapcount() on the head page does not tell the whole story.
We should check each individual page. In a future without per-page mapcounts it will be different, but we'll change that to be consistent with PTE-mapped THPs once we deal with that.
--- fs/proc/task_mmu.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
fs/proc/task_mmu.c +12 -10
@@ -1477,6 +1477,7 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmdp, vma);if (ptl) { +unsigned int idx = (addr & ~PMD_MASK ) >>PAGE_SHIFT ;u64 flags =0 , frame =0 ;pmd_t pmd = *pmdp;struct page *page =NULL ;
@@ -1493,8 +1494,7 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,if (pmd_uffd_wp (pmd)) flags |=PM_UFFD_WP ;if (pm->show_pfn) - frame =pmd_pfn (pmd) + - ((addr & ~PMD_MASK ) >>PAGE_SHIFT ); + frame =pmd_pfn (pmd) + idx; }#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION else if (is_swap_pmd(pmd)) {
@@ -1503,11 +1503,9 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,if (pm->show_pfn) {if (is_pfn_swap_entry (entry)) - offset =swp_offset_pfn (entry); + offset =swp_offset_pfn (entry) + idx;else - offset =swp_offset (entry); - offset = offset + - ((addr & ~PMD_MASK ) >>PAGE_SHIFT ); + offset =swp_offset (entry) + idx; frame =swp_type (entry) | (offset <<MAX_SWAPFILES_SHIFT ); }
@@ -1523,12 +1521,16 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,if (page && !PageAnon (page)) flags |=PM_FILE ; -if (page && (flags &PM_PRESENT ) &&page_mapcount (page) ==1 ) - flags |=PM_MMAP_EXCLUSIVE ; -for (; addr != end; addr +=PAGE_SIZE ) { -pagemap_entry_t pme =make_pme (frame, flags); +for (; addr != end; addr +=PAGE_SIZE , idx++) { +unsigned long cur_flags = flags; +pagemap_entry_t pme; + +if (page && (flags &PM_PRESENT ) && +page_mapcount (page + idx) ==1 ) + cur_flags |=PM_MMAP_EXCLUSIVE ; + pme =make_pme (frame, cur_flags); err =add_to_pagemap (&pme, pm);if (err)break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 511/809 selftests/damon/access_memory: use user-defined region size
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
[ Upstream commit 34ec4344a5dabbb39e23e8daf30779892c0211a6 ]
Patch series "selftests/damon: test DAMOS tried regions and {min,max}_nr_regions".
This patch series fix a minor issue in a program for DAMON selftest, and implement new functionality selftests for DAMOS tried regions and {min,max}_nr_regions. The test for max_nr_regions also test the recovery from online tuning-caused limit violation, which was fixed by a previous patch [1] titled "mm/damon/core: merge regions aggressively when max_nr_regions is unmet".
The first patch fixes a minor problem in the articial memory access pattern generator for tests. Following 3 patches (2-4) implement schemes tried regions test. Then a couple of patches (5-6) implementing static setup based {min,max}_nr_regions functionality test follows. Final two patches (7-8) implement dynamic max_nr_regions update test.
[1] https://lore.kernel.org/[email protected]
This patch (of 8):
'access_memory' is an artificial memory access pattern generator for DAMON tests. It creates and accesses memory regions that the user specified the number and size via the command line. However, real access part of the program ignores the user-specified size of each region. Instead, it uses a hard-coded value, 10 MiB. Fix it to use user-defined size.
Note that all existing 'access_memory' users are setting the region size as 10 MiB. Hence no real problem has happened so far.
--- tools/testing/selftests/damon/access_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/damon/access_memory.c +1 -1
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) start_clock =clock ();while ((clock () - start_clock) *1000 /CLOCKS_PER_SEC < access_time_ms) -memset (regions[i], i,1024 *1024 *10 ); +memset (regions[i], i, sz_region); }return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 512/809 nilfs2: avoid undefined behavior in nilfs_cnt32_ge macro
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 0f3819e8c483771a59cf9d3190cd68a7a990083c ]
According to the C standard 3.4.3p3, the result of signed integer overflow is undefined. The macro nilfs_cnt32_ge(), which compares two sequence numbers, uses signed integer subtraction that can overflow, and therefore the result of the calculation may differ from what is expected due to undefined behavior in different environments.
Similar to an earlier change to the jiffies-related comparison macros in commit 5a581b367b5d ("jiffies: Avoid undefined behavior from signed overflow"), avoid this potential issue by changing the definition of the macro to perform the subtraction as unsigned integers, then cast the result to a signed integer for comparison.
--- fs/nilfs2/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/segment.c +1 -1
@@ -136,7 +136,7 @@ static void nilfs_dispose_list(struct the_nilfs *, struct list_head *, int);#define nilfs_cnt32_ge (a, b) \ (typecheck(__u32, a) && typecheck(__u32, b) && \ - ((__s32)(a) - (__s32)(b) >= 0)) + ((__s32)((a) - (b)) >= 0))static int nilfs_prepare_segment_lock (struct super_block *sb,struct nilfs_transaction_info *ti)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 513/809 rtc: interface: Add RTC offset to alarm after fix-up
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Csókás, Bence <[email protected]>
[ Upstream commit 463927a8902a9f22c3633960119410f57d4c8920 ]
rtc_add_offset() is called by __rtc_read_time() and __rtc_read_alarm() to add the RTC's offset to the raw read-outs from the device drivers. However, in the latter case, a fix-up algorithm is run if the RTC device does not report a full struct rtc_time alarm value. In that case, the offset was forgot to be added.
--- drivers/rtc/interface.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/rtc/interface.c +5 -4
@@ -274,10 +274,9 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)return err;/* full-function RTCs won't have such missing fields */ -if (rtc_valid_tm (&alarm->time) ==0 ) { -rtc_add_offset (rtc, &alarm->time); -return 0 ; - } + err =rtc_valid_tm (&alarm->time); +if (!err) + goto done;/* get the "after" timestamp, to detect wrapped fields */ err =rtc_read_time (rtc, &now);
@@ -379,6 +378,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)if (err && alarm->enabled)dev_warn (&rtc->dev,"invalid alarm value: %ptR\n" , &alarm->time); +else +rtc_add_offset (rtc, &alarm->time);return err; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 514/809 fs/ntfs3: Fix the format of the "nocase" mount option
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit d392e85fd1e8d58e460c17ca7d0d5c157848d9c1 ]
The 'nocase' option was mistakenly added as fsparam_flag_no with the 'no' prefix, causing the case-insensitive mode to require the 'nonocase' option to be enabled.
--- fs/ntfs3/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/super.c +1 -1
@@ -275,7 +275,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {fsparam_flag_no ("acl" , Opt_acl),fsparam_string ("iocharset" , Opt_iocharset),fsparam_flag_no ("prealloc" , Opt_prealloc), - fsparam_flag_no("nocase", Opt_nocase), + fsparam_flag_no("case", Opt_nocase), {} };// clang-format on
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 515/809 fs/ntfs3: Missed error return
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit 2cbbd96820255fff4f0ad1533197370c9ccc570b ]
--- fs/ntfs3/bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/bitmap.c +1 -1
@@ -1382,7 +1382,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits) err =ntfs_vbo_to_lbo (sbi, &wnd->run, vbo, &lbo, &bytes);if (err) -break ; +return err; bh =ntfs_bread (sb, lbo >> sb->s_blocksize_bits);if (!bh)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 516/809 fs/ntfs3: Keep runs for $MFT::$ATTR_DATA and $MFT::$ATTR_BITMAP
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit eb95678ee930d67d79fc83f0a700245ae7230455 ]
We skip the run_truncate_head call also for $MFT::$ATTR_BITMAP.
Otherwise wnd_map()/run_lookup_entry will not find the disk position for the bitmap parts.
--- fs/ntfs3/attrib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ntfs3/attrib.c +2 -1
@@ -673,7 +673,8 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, goto undo_2; } -if (!is_mft) +/* keep runs for $MFT::$ATTR_DATA and $MFT::$ATTR_BITMAP. */ +if (ni->mi.rno !=MFT_REC_MFT )run_truncate_head (run, evcn +1 ); svcn =le64_to_cpu (attr->nres.svcn);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 517/809 md-cluster: fix hanging issue while a new disk adding
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heming Zhao <[email protected]>
[ Upstream commit fff42f213824fa434a4b6cf906b4331fe6e9302b ]
The commit 1bbe254e4336 ("md-cluster: check for timeout while a new disk adding") is correct in terms of code syntax but not suite real clustered code logic.
When a timeout occurs while adding a new disk, if recv_daemon() bypasses the unlock for ack_lockres:CR, another node will be waiting to grab EX lock. This will cause the cluster to hang indefinitely.
How to fix:
1. In dlm_lock_sync(), change the wait behaviour from forever to a timeout, This could avoid the hanging issue when another node fails to handle cluster msg. Another result of this change is that if another node receives an unknown msg (e.g. a new msg_type), the old code will hang, whereas the new code will timeout and fail. This could help cluster_md handle new msg_type from different nodes with different kernel/module versions (e.g. The user only updates one leg's kernel and monitors the stability of the new kernel).
2. The old code for __sendmsg() always returns 0 (success) under the design (must successfully unlock ->message_lockres). This commit makes this function return an error number when an error occurs.
--- drivers/md/md-cluster.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/md/md-cluster.c +12 -10
@@ -15,6 +15,7 @@#define LVB_SIZE 64#define NEW_DEV_TIMEOUT 5000 +#define WAIT_DLM_LOCK_TIMEOUT (30 * HZ)struct dlm_lock_resource {dlm_lockspace_t *ls;
@@ -130,8 +131,13 @@ static int dlm_lock_sync(struct dlm_lock_resource *res, int mode) 0, sync_ast, res, res->bast);if (ret)return ret; -wait_event (res->sync_locking, res->sync_locking_done); + ret =wait_event_timeout (res->sync_locking, res->sync_locking_done, +WAIT_DLM_LOCK_TIMEOUT ); res->sync_locking_done = false; +if (!ret) { +pr_err ("locking DLM '%s' timeout!\n" , res->name); +return -EBUSY ; + }if (res->lksb.sb_status ==0 ) res->mode = mode;return res->lksb.sb_status;
@@ -743,7 +749,7 @@ static void unlock_comm(struct md_cluster_info *cinfo)*/ static int __sendmsg (struct md_cluster_info *cinfo,struct cluster_msg *cmsg) { -int error; +int error, unlock_error;int slot = cinfo->slot_number -1 ; cmsg->slot =cpu_to_le32 (slot);
@@ -751,7 +757,7 @@ static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg) error =dlm_lock_sync (cinfo->message_lockres,DLM_LOCK_EX );if (error) {pr_err ("md-cluster: failed to get EX on MESSAGE (%d)\n" , error); - goto failed_message; +return error; } memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg,
@@ -781,14 +787,10 @@ static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg) } failed_ack: - error =dlm_unlock_sync (cinfo->message_lockres); -if (unlikely (error !=0 )) { +while ((unlock_error =dlm_unlock_sync (cinfo->message_lockres)))pr_err ("md-cluster: failed convert to NL on MESSAGE(%d)\n" , - error); -/* in case the message can't be released due to some reason */ - goto failed_ack; - } -failed_message: + unlock_error); +return error; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 518/809 powerpc/8xx: fix size given to set_huge_pte_at()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 7ea981070fd9ec24bc0111636038193aebb0289c ]
set_huge_pte_at() expects the size of the hugepage as an int, not the psize which is the index of the page definition in table mmu_psize_defs[]
--- arch/powerpc/mm/nohash/8xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/mm/nohash/8xx.c +2 -1
@@ -94,7 +94,8 @@ static int __ref __early_map_kernel_hugepage(unsigned long va, phys_addr_t pa,return -EINVAL ;set_huge_pte_at (&init_mm, va, ptep, -pte_mkhuge (pfn_pte (pa >>PAGE_SHIFT , prot)), psize); +pte_mkhuge (pfn_pte (pa >>PAGE_SHIFT , prot)), +1UL <<mmu_psize_to_shift (psize));return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 519/809 s390/dasd: fix error checks in dasd_copy_pair_store()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos López <[email protected]>
[ Upstream commit 8e64d2356cbc800b4cd0e3e614797f76bcf0cdb8 ]
dasd_add_busid() can return an error via ERR_PTR() if an allocation fails. However, two callsites in dasd_copy_pair_store() do not check the result, potentially resulting in a NULL pointer dereference. Fix this by checking the result with IS_ERR() and returning the error up the stack.
--- drivers/s390/block/dasd_devmap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/s390/block/dasd_devmap.c +8 -2
@@ -2248,13 +2248,19 @@ static ssize_t dasd_copy_pair_store(struct device *dev,/* allocate primary devmap if needed */ prim_devmap =dasd_find_busid (prim_busid); -if (IS_ERR (prim_devmap)) +if (IS_ERR (prim_devmap)) { prim_devmap =dasd_add_busid (prim_busid,DASD_FEATURE_DEFAULT ); +if (IS_ERR (prim_devmap)) +return PTR_ERR (prim_devmap); + }/* allocate secondary devmap if needed */ sec_devmap =dasd_find_busid (sec_busid); -if (IS_ERR (sec_devmap)) +if (IS_ERR (sec_devmap)) { sec_devmap =dasd_add_busid (sec_busid,DASD_FEATURE_DEFAULT ); +if (IS_ERR (sec_devmap)) +return PTR_ERR (sec_devmap); + }/* setting copy relation is only allowed for offline secondary */ if (sec_devmap->device)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 520/809 lib: add missing newline character in the warning message
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit 4810a82c8a8ae06fe6496a23fcb89a4952603e60 ]
--- include/linux/alloc_tag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/alloc_tag.h +1 -1
@@ -122,7 +122,7 @@ static inline void alloc_tag_add_check(union codetag_ref *ref, struct alloc_tag"alloc_tag was not cleared (got tag for %s:%u)\n" , ref->ct->filename, ref->ct->lineno); -WARN_ONCE (!tag,"current->alloc_tag not set" ); +WARN_ONCE (!tag,"current->alloc_tag not set\n" ); }static inline void alloc_tag_sub_check (union codetag_ref *ref)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 521/809 lib: reuse page_ext_data() to obtain codetag_ref
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit fd8acc0097b91fab3104fa8a66ce2fd9cf8b0c11 ]
codetag_ref_from_page_ext() reimplements the same calculation as page_ext_data(). Reuse existing function instead.
--- include/linux/pgalloc_tag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pgalloc_tag.h +1 -1
@@ -15,7 +15,7 @@ extern struct page_ext_operations page_alloc_tagging_ops;static inline union codetag_ref *codetag_ref_from_page_ext (struct page_ext *page_ext) { -return (void *)page_ext + page_alloc_tagging_ops.offset; +return (union codetag_ref *)page_ext_data (page_ext, &page_alloc_tagging_ops); }static inline struct page_ext *page_ext_from_codetag_ref (union codetag_ref *ref)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 522/809 alloc_tag: fix page_ext_get/page_ext_put sequence during page splitting
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit 6ab42fe21c84d72da752923b4bd7075344f4a362 ]
pgalloc_tag_sub() might call page_ext_put() using a page different from the one used in page_ext_get() call. This does not pose an issue since page_ext_put() ignores this parameter as long as it's non-NULL but technically this is wrong. Fix it by storing the original page used in page_ext_get() and passing it to page_ext_put().
--- include/linux/pgalloc_tag.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/pgalloc_tag.h +3 -2
@@ -71,6 +71,7 @@ static inline void pgalloc_tag_sub(struct page *page, unsigned int nr)static inline void pgalloc_tag_split (struct page *page,unsigned int nr) {int i; +struct page_ext *first_page_ext;struct page_ext *page_ext;union codetag_ref *ref;struct alloc_tag *tag;
@@ -78,7 +79,7 @@ static inline void pgalloc_tag_split(struct page *page, unsigned int nr)if (!mem_alloc_profiling_enabled ())return ; - page_ext =page_ext_get (page); + first_page_ext = page_ext =page_ext_get (page);if (unlikely (!page_ext))return ;
@@ -94,7 +95,7 @@ static inline void pgalloc_tag_split(struct page *page, unsigned int nr) page_ext =page_ext_next (page_ext); } out: -page_ext_put (page_ext); +page_ext_put (first_page_ext); }static inline struct alloc_tag *pgalloc_tag_get (struct page *page)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 523/809 sbitmap: fix io hung due to race on sbitmap_word::cleared
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Yang <[email protected]>
[ Upstream commit 72d04bdcf3f7d7e07d82f9757946f68802a7270a ]
Configuration for sbq:
depth=64, wake_batch=6, shift=6, map_nr=1
1. There are 64 requests in progress:
map->word = 0xFFFFFFFFFFFFFFFF
2. After all the 64 requests complete, and no more requests come:
map->word = 0xFFFFFFFFFFFFFFFF, map->cleared = 0xFFFFFFFFFFFFFFFF
3. Now two tasks try to allocate requests:
T1: T2:
__blk_mq_get_tag .
__sbitmap_queue_get .
sbitmap_get .
sbitmap_find_bit .
sbitmap_find_bit_in_word .
__sbitmap_get_word -> nr=-1 __blk_mq_get_tag
sbitmap_deferred_clear __sbitmap_queue_get
/* map->cleared=0xFFFFFFFFFFFFFFFF */ sbitmap_find_bit
if (!READ_ONCE(map->cleared)) sbitmap_find_bit_in_word
return false; __sbitmap_get_word -> nr=-1
mask = xchg(&map->cleared, 0) sbitmap_deferred_clear
atomic_long_andnot() /* map->cleared=0 */
if (!(map->cleared))
return false;
/*
* map->cleared is cleared by T1
* T2 fail to acquire the tag
*/4. T2 is the sole tag waiter. When T1 puts the tag, T2 cannot be woken up due to the wake_batch being set at 6. If no more requests come, T1 will wait here indefinitely.
This patch achieves two purposes:
1. Check on ->cleared and update on both ->cleared and ->word need to be done atomically, and using spinlock could be the simplest solution.
2. Add extra check in sbitmap_deferred_clear(), to identify whether ->word has free bits.
--- include/linux/sbitmap.h | 5 +++++ lib/sbitmap.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-)
include/linux/sbitmap.h +5 -0
@@ -36,6 +36,11 @@ struct sbitmap_word {* @cleared: word holding cleared bits */ unsigned long cleared____cacheline_aligned_in_smp ; + +/** +* @swap_lock: serializes simultaneous updates of ->word and ->cleared +*/ +spinlock_t swap_lock; }____cacheline_aligned_in_smp ;/**
lib/sbitmap.c +29 -7
@@ -60,12 +60,30 @@ static inline void update_alloc_hint_after_get(struct sbitmap *sb,/* * See if we have deferred clears that we can batch move */ -static inline bool sbitmap_deferred_clear (struct sbitmap_word *map) +static inline bool sbitmap_deferred_clear (struct sbitmap_word *map, +unsigned int depth,unsigned int alloc_hint,bool wrap) { -unsigned long mask; +unsigned long mask, word_mask; -if (!READ_ONCE (map->cleared)) -return false; +guard (spinlock_irqsave)(&map->swap_lock); + +if (!map->cleared) { +if (depth ==0 ) +return false; + + word_mask = (~0UL ) >> (BITS_PER_LONG - depth); +/* +* The current behavior is to always retry after moving +* ->cleared to word, and we change it to retry in case +* of any free bits. To avoid an infinite loop, we need +* to take wrap & alloc_hint into account, otherwise a +* soft lockup may occur. +*/ +if (!wrap && alloc_hint) + word_mask &= ~((1UL << alloc_hint) -1 ); + +return (READ_ONCE (map->word) & word_mask) != word_mask; + }/* * First get a stable cleared mask, setting the old mask to 0.
@@ -85,6 +103,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, bool alloc_hint) {unsigned int bits_per_word; +int i;if (shift <0 ) shift =sbitmap_calculate_shift (depth);
@@ -116,6 +135,9 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,return -ENOMEM ; } +for (i =0 ; i < sb->map_nr; i++) +spin_lock_init (&sb->map[i].swap_lock); +return 0 ; }EXPORT_SYMBOL_GPL (sbitmap_init_node);
@@ -126,7 +148,7 @@ void sbitmap_resize(struct sbitmap *sb, unsigned int depth)unsigned int i;for (i =0 ; i < sb->map_nr; i++) -sbitmap_deferred_clear (&sb->map[i]); +sbitmap_deferred_clear (&sb->map[i],0 ,0 ,0 ); sb->depth = depth; sb->map_nr =DIV_ROUND_UP (sb->depth, bits_per_word);
@@ -179,7 +201,7 @@ static int sbitmap_find_bit_in_word(struct sbitmap_word *map, alloc_hint, wrap);if (nr !=-1 )break ; -if (!sbitmap_deferred_clear (map)) +if (!sbitmap_deferred_clear (map, depth, alloc_hint, wrap))break ; }while (1 );
@@ -496,7 +518,7 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags,unsigned int map_depth =__map_depth (sb, index);unsigned long val; -sbitmap_deferred_clear (map); +sbitmap_deferred_clear (map,0 ,0 ,0 ); val =READ_ONCE (map->word);if (val == (1UL << (map_depth -1 )) -1 ) goto next;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 524/809 LoongArch: Check TIF_LOAD_WATCH to enable user space watchpoint
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
[ Upstream commit 3892b11eac5aaaeefbf717f1953288b77759d9e2 ]
Currently, there are some places to set CSR.PRMD.PWE, the first one is in hw_breakpoint_thread_switch() to enable user space singlestep via checking TIF_SINGLESTEP, the second one is in hw_breakpoint_control() to enable user space watchpoint. For the latter case, it should also check TIF_LOAD_WATCH to make the logic correct and clear.
--- arch/loongarch/kernel/hw_breakpoint.c | 2 +- arch/loongarch/kernel/ptrace.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
arch/loongarch/kernel/hw_breakpoint.c +1 -1
@@ -221,7 +221,7 @@ static int hw_breakpoint_control(struct perf_event *bp, } enable =csr_read64 (LOONGARCH_CSR_CRMD );csr_write64 (CSR_CRMD_WE | enable,LOONGARCH_CSR_CRMD ); -if (bp->hw.target) +if (bp->hw.target &&test_tsk_thread_flag (bp->hw.target,TIF_LOAD_WATCH )) regs->csr_prmd |=CSR_PRMD_PWE ;break ;case HW_BREAKPOINT_UNINSTALL :
arch/loongarch/kernel/ptrace.c +3 -0
@@ -589,6 +589,7 @@ static int ptrace_hbp_set_ctrl(unsigned int note_type,struct perf_event *bp;struct perf_event_attr attr;struct arch_hw_breakpoint_ctrl ctrl; +struct thread_info *ti =task_thread_info (tsk); bp =ptrace_hbp_get_initialised_bp (note_type, tsk, idx);if (IS_ERR (bp))
@@ -613,8 +614,10 @@ static int ptrace_hbp_set_ctrl(unsigned int note_type,if (err)return err; attr.disabled =0 ; +set_ti_thread_flag (ti,TIF_LOAD_WATCH ); }else { attr.disabled =1 ; +clear_ti_thread_flag (ti,TIF_LOAD_WATCH ); }return modify_user_hw_breakpoint (bp, &attr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 525/809 power: supply: ab8500: Fix error handling when calling iio_read_channel_processed()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit 3288757087cbb93b91019ba6b7de53a1908c9d48 ]
The ab8500_charger_get_[ac|vbus]_[current|voltage]() functions should return an error code on error.
Up to now, an un-initialized value is returned. This makes the error handling of the callers un-reliable.
Return the error code instead, to fix the issue.
--- drivers/power/supply/ab8500_charger.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/power/supply/ab8500_charger.c +12 -4
@@ -488,8 +488,10 @@ static int ab8500_charger_get_ac_voltage(struct ab8500_charger *di)/* Only measure voltage if the charger is connected */ if (di->ac.charger_connected) { ret =iio_read_channel_processed (di->adc_main_charger_v, &vch); -if (ret <0 ) +if (ret <0 ) {dev_err (di->dev,"%s ADC conv failed,\n" , __func__); +return ret; + } }else { vch =0 ; }
@@ -540,8 +542,10 @@ static int ab8500_charger_get_vbus_voltage(struct ab8500_charger *di)/* Only measure voltage if the charger is connected */ if (di->usb.charger_connected) { ret =iio_read_channel_processed (di->adc_vbus_v, &vch); -if (ret <0 ) +if (ret <0 ) {dev_err (di->dev,"%s ADC conv failed,\n" , __func__); +return ret; + } }else { vch =0 ; }
@@ -563,8 +567,10 @@ static int ab8500_charger_get_usb_current(struct ab8500_charger *di)/* Only measure current if the charger is online */ if (di->usb.charger_online) { ret =iio_read_channel_processed (di->adc_usb_charger_c, &ich); -if (ret <0 ) +if (ret <0 ) {dev_err (di->dev,"%s ADC conv failed,\n" , __func__); +return ret; + } }else { ich =0 ; }
@@ -586,8 +592,10 @@ static int ab8500_charger_get_ac_current(struct ab8500_charger *di)/* Only measure current if the charger is online */ if (di->ac.charger_online) { ret =iio_read_channel_processed (di->adc_main_charger_c, &ich); -if (ret <0 ) +if (ret <0 ) {dev_err (di->dev,"%s ADC conv failed,\n" , __func__); +return ret; + } }else { ich =0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 526/809 power: supply: ingenic: Fix some error handling paths in ingenic_battery_get_property()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit f8b6c1eb76f73ed721facd58d0cfb08513aad34c ]
If iio_read_channel_processed() fails, 'val->intval' is not updated, but it is still *1000 just after. So, in case of error, the *1000 accumulate and 'val->intval' becomes erroneous.
So instead of rescaling the value after the fact, use the dedicated scaling API. This way the result is updated only when needed. In case of error, the previous value is kept, unmodified.
This should also reduce any inaccuracies resulting from the scaling.
Finally, this is also slightly more efficient as it saves a function call and a multiplication.
--- drivers/power/supply/ingenic-battery.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/power/supply/ingenic-battery.c +6 -4
@@ -31,8 +31,9 @@ static int ingenic_battery_get_property(struct power_supply *psy,switch (psp) {case POWER_SUPPLY_PROP_HEALTH : - ret =iio_read_channel_processed (bat->channel, &val->intval); - val->intval *=1000 ; + ret =iio_read_channel_processed_scale (bat->channel, + &val->intval, +1000 );if (val->intval < info->voltage_min_design_uv) val->intval =POWER_SUPPLY_HEALTH_DEAD ;else if (val->intval > info->voltage_max_design_uv)
@@ -41,8 +42,9 @@ static int ingenic_battery_get_property(struct power_supply *psy, val->intval =POWER_SUPPLY_HEALTH_GOOD ;return ret;case POWER_SUPPLY_PROP_VOLTAGE_NOW : - ret =iio_read_channel_processed (bat->channel, &val->intval); - val->intval *=1000 ; + ret =iio_read_channel_processed_scale (bat->channel, + &val->intval, +1000 );return ret;case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN : val->intval = info->voltage_min_design_uv;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 527/809 remoteproc: mediatek: Dont attempt to remap l1tcm memory if missing
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nícolas F. R. A. Prado <[email protected]>
[ Upstream commit 67ca3f98070ffdf308b91e08a477fcb1e9684ae8 ]
The current code doesn't check whether platform_get_resource_byname() succeeded to get the l1tcm memory, which is optional, before attempting to map it. This results in the following error message when it is missing:
mtk-scp 10500000.scp: error -EINVAL: invalid resource (null)
Add a check so that the remapping is only attempted if the memory region exists. This also allows to simplify the logic handling failure to remap, since a failure then is always a failure.
--- drivers/remoteproc/mtk_scp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/remoteproc/mtk_scp.c +5 -7
@@ -1344,14 +1344,12 @@ static int scp_probe(struct platform_device *pdev)/* l1tcm is an optional memory region */ res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"l1tcm" ); - scp_cluster->l1tcm_base =devm_ioremap_resource (dev, res); -if (IS_ERR (scp_cluster->l1tcm_base)) { - ret =PTR_ERR (scp_cluster->l1tcm_base); -if (ret != -EINVAL ) -return dev_err_probe (dev, ret,"Failed to map l1tcm memory\n" ); +if (res) { + scp_cluster->l1tcm_base =devm_ioremap_resource (dev, res); +if (IS_ERR (scp_cluster->l1tcm_base)) +return dev_err_probe (dev,PTR_ERR (scp_cluster->l1tcm_base), +"Failed to map l1tcm memory\n" ); - scp_cluster->l1tcm_base =NULL ; - }else { scp_cluster->l1tcm_size =resource_size (res); scp_cluster->l1tcm_phys = res->start; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 528/809 remoteproc: k3-r5: Fix IPC-only mode detection
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Genoud <[email protected]>
[ Upstream commit a8631f6d6344d976096b1efafdb2fbb3111bd790 ]
ret variable was used to test reset status, get from reset_control_status() call. But this variable was overwritten by ti_sci_proc_get_status() a few lines bellow.
And as ti_sci_proc_get_status() returns 0 or a negative value (in this latter case, followed by a return), the expression !ret was always true,
Clearly, this was not what was intended:
In the comment above it's said that "requires both local and module resets to be deasserted"; if reset_control_status() returns 0 it means that the reset line is deasserted.
So, it's pretty clear that the return value of reset_control_status() was intended to be used instead of ti_sci_proc_get_status() return value.
This could lead in an incorrect IPC-only mode detection if reset line is asserted (so reset_control_status() return > 0) and c_state != 0 and halted == 0.
In this case, the old code would have detected an IPC-only mode instead of a mismatched mode.
--- drivers/remoteproc/ti_k3_r5_remoteproc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/remoteproc/ti_k3_r5_remoteproc.c +7 -6
@@ -1144,6 +1144,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)u32 atcm_enable, btcm_enable, loczrama;struct k3_r5_core *core0;enum cluster_mode mode = cluster->mode; +int reset_ctrl_status;int ret; core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem);
@@ -1160,11 +1161,11 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc) r_state, c_state); } - ret =reset_control_status (core->reset); -if (ret <0 ) { + reset_ctrl_status =reset_control_status (core->reset); +if (reset_ctrl_status <0 ) {dev_err (cdev,"failed to get initial local reset status, ret = %d\n" , - ret); -return ret; + reset_ctrl_status); +return reset_ctrl_status; }/*
@@ -1199,7 +1200,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)* irrelevant if module reset is asserted (POR value has local reset * deasserted), and is deemed as remoteproc mode */ -if (c_state && !ret && !halted) { +if (c_state && !reset_ctrl_status && !halted) {dev_info (cdev,"configured R5F for IPC-only mode\n" ); kproc->rproc->state =RPROC_DETACHED ; ret =1 ;
@@ -1217,7 +1218,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc) ret =0 ; }else {dev_err (cdev,"mismatched mode: local_reset = %s, module_reset = %s, core_state = %s\n" , - !ret ?"deasserted" :"asserted" , + !reset_ctrl_status ?"deasserted" :"asserted" , c_state ?"deasserted" :"asserted" , halted ?"halted" :"unhalted" ); ret = -EINVAL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 529/809 mailbox: omap: Fix mailbox interrupt sharing
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Davis <[email protected]>
[ Upstream commit 0a02bc0a34cd53c7fe5bf4bae6efb56ad47677fa ]
Multiple mailbox users can share one interrupt line. This flag was mistakenly dropped as part of the FIFO removal. Mark the IRQ as shared.
--- drivers/mailbox/omap-mailbox.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mailbox/omap-mailbox.c +2 -1
@@ -230,7 +230,8 @@ static int omap_mbox_startup(struct omap_mbox *mbox)int ret =0 ; ret =request_threaded_irq (mbox->irq,NULL , mbox_interrupt, -IRQF_ONESHOT , mbox->name, mbox); +IRQF_SHARED |IRQF_ONESHOT , mbox->name, + mbox);if (unlikely (ret)) {pr_err ("failed to register mailbox interrupt:%d\n" , ret);return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 530/809 mailbox: imx: fix TXDB_V2 channel race condition
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit b5ef17917f3a797a7b12d1edd51f676554e44a07 ]
Two TXDB_V2 channels are used between Linux and System Manager(SM). Channel0 for normal TX, Channel 1 for notification completion. The TXDB_V2 trigger logic is using imx_mu_xcr_rmw which uses read/modify/update logic.
Note: clear MUB GSR BITs, the MUA side GCR BITs will also got cleared per hardware design.
Channel0 Linux
read GCR->modify GCR->write GCR->M33 SM->read GSR----->clear GSR
|-(1)-|
Channel1 Linux start in time slot(1)
read GCR->modify GCR->write GCR->M33 SM->read GSR->clear GSR So Channel1 read GCR will read back the GCR that Channel0 wrote, because M33 has not finish clear GSR, this means Channel1 GCR writing will trigger Channel1 and Channel0 interrupt both which is wrong.
Channel0 will be freed(SCMI channel status set to FREE) in M33 SM when processing the 1st Channel0 interrupt. So when 2nd interrupt trigger (channel 0/1 trigger together), SM will see a freed Channel0, and report protocol error.
To address the issue, not using read/modify/update logic, just use write, because write 0 to GCR will be ignored. And after write MUA GCR, wait the SM to clear MUB GSR by looping MUA GCR value.
--- drivers/mailbox/imx-mailbox.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/mailbox/imx-mailbox.c +9 -1
@@ -225,6 +225,8 @@ static int imx_mu_generic_tx(struct imx_mu_priv *priv, void *data) {u32 *arg = data; +u32 val; +int ret;switch (cp->type) {case IMX_MU_TYPE_TX :
@@ -236,7 +238,13 @@ static int imx_mu_generic_tx(struct imx_mu_priv *priv,queue_work (system_bh_wq, &cp->txdb_work);break ;case IMX_MU_TYPE_TXDB_V2 : -imx_mu_xcr_rmw (priv,IMX_MU_GCR ,IMX_MU_xCR_GIRn (priv->dcfg->type, cp->idx),0 ); +imx_mu_write (priv,IMX_MU_xCR_GIRn (priv->dcfg->type, cp->idx), + priv->dcfg->xCR[IMX_MU_GCR ]); + ret =readl_poll_timeout (priv->base + priv->dcfg->xCR[IMX_MU_GCR ], val, + !(val &IMX_MU_xCR_GIRn (priv->dcfg->type, cp->idx)), +0 ,1000 ); +if (ret) +dev_warn_ratelimited (priv->dev,"channel type: %d failure\n" , cp->type);break ;default :dev_warn_ratelimited (priv->dev,"Send data on wrong channel type: %d\n" , cp->type);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 531/809 mailbox: mtk-cmdq: Move devm_mbox_controller_register() after devm_pm_runtime_enable()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason-JH.Lin <[email protected]>
[ Upstream commit a8bd68e4329f9a0ad1b878733e0f80be6a971649 ]
When mtk-cmdq unbinds, a WARN_ON message with condition pm_runtime_get_sync() < 0 occurs.
According to the call tracei below:
cmdq_mbox_shutdown
mbox_free_channel
mbox_controller_unregister
__devm_mbox_controller_unregister
...
The root cause can be deduced to be calling pm_runtime_get_sync() after calling pm_runtime_disable() as observed below:
1. CMDQ driver uses devm_mbox_controller_register() in cmdq_probe() to bind the cmdq device to the mbox_controller, so devm_mbox_controller_unregister() will automatically unregister the device bound to the mailbox controller when the device-managed resource is removed. That means devm_mbox_controller_unregister() and cmdq_mbox_shoutdown() will be called after cmdq_remove().
2. CMDQ driver also uses devm_pm_runtime_enable() in cmdq_probe() after devm_mbox_controller_register(), so that devm_pm_runtime_disable() will be called after cmdq_remove(), but before devm_mbox_controller_unregister().
To fix this problem, cmdq_probe() needs to move devm_mbox_controller_register() after devm_pm_runtime_enable() to make devm_pm_runtime_disable() be called after devm_mbox_controller_unregister().
--- drivers/mailbox/mtk-cmdq-mailbox.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mailbox/mtk-cmdq-mailbox.c +6 -6
@@ -662,12 +662,6 @@ static int cmdq_probe(struct platform_device *pdev) cmdq->mbox.chans[i].con_priv = (void *)&cmdq->thread[i]; } - err =devm_mbox_controller_register (dev, &cmdq->mbox); -if (err <0 ) { -dev_err (dev,"failed to register mailbox: %d\n" , err); -return err; - } -platform_set_drvdata (pdev, cmdq);WARN_ON (clk_bulk_prepare (cmdq->pdata->gce_num, cmdq->clocks));
@@ -695,6 +689,12 @@ static int cmdq_probe(struct platform_device *pdev)pm_runtime_set_autosuspend_delay (dev,CMDQ_MBOX_AUTOSUSPEND_DELAY_MS );pm_runtime_use_autosuspend (dev); + err =devm_mbox_controller_register (dev, &cmdq->mbox); +if (err <0 ) { +dev_err (dev,"failed to register mailbox: %d\n" , err); +return err; + } +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 532/809 selftests/landlock: Add cred_transfer test
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
commit cc374782b6ca0fd634482391da977542443d3368 upstream.
Check that keyctl(KEYCTL_SESSION_TO_PARENT) preserves the parent's restrictions.
--- tools/testing/selftests/landlock/base_test.c | 74 +++++++++++++++++++++++++++ tools/testing/selftests/landlock/config | 1 2 files changed, 75 insertions(+)
tools/testing/selftests/landlock/base_test.c +74 -0
@@ -9,6 +9,7 @@#define _GNU_SOURCE#include <errno.h> #include <fcntl.h> +#include <linux/keyctl.h> #include <linux/landlock.h> #include <string.h> #include <sys/prctl.h>
@@ -326,4 +327,77 @@ TEST(ruleset_fd_transfer)ASSERT_EQ (EXIT_SUCCESS ,WEXITSTATUS (status)); } +TEST (cred_transfer) +{ +struct landlock_ruleset_attr ruleset_attr = { + .handled_access_fs =LANDLOCK_ACCESS_FS_READ_DIR , + }; +int ruleset_fd, dir_fd; +pid_t child; +int status; + +drop_caps (_metadata); + + dir_fd =open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC ); +EXPECT_LE (0 , dir_fd); +EXPECT_EQ (0 ,close (dir_fd)); + +/* Denies opening directories. */ + ruleset_fd = +landlock_create_ruleset (&ruleset_attr,sizeof (ruleset_attr),0 ); +ASSERT_LE (0 , ruleset_fd); +EXPECT_EQ (0 ,prctl (PR_SET_NO_NEW_PRIVS ,1 ,0 ,0 ,0 )); +ASSERT_EQ (0 ,landlock_restrict_self (ruleset_fd,0 )); +EXPECT_EQ (0 ,close (ruleset_fd)); + +/* Checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); + +/* Needed for KEYCTL_SESSION_TO_PARENT permission checks */ +EXPECT_NE (-1 ,syscall (__NR_keyctl,KEYCTL_JOIN_SESSION_KEYRING ,NULL ,0 , + 0, 0)) + { +TH_LOG ("Failed to join session keyring: %s" ,strerror (errno)); + } + + child =fork (); +ASSERT_LE (0 , child); +if (child ==0 ) { +/* Checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); + +/* +* KEYCTL_SESSION_TO_PARENT is a no-op unless we have a +* different session keyring in the child, so make that happen. +*/ +EXPECT_NE (-1 ,syscall (__NR_keyctl,KEYCTL_JOIN_SESSION_KEYRING , +NULL ,0 ,0 ,0 )); + +/* +* KEYCTL_SESSION_TO_PARENT installs credentials on the parent +* that never go through the cred_prepare hook, this path uses +* cred_transfer instead. +*/ +EXPECT_EQ (0 ,syscall (__NR_keyctl,KEYCTL_SESSION_TO_PARENT ,0 , +0 ,0 ,0 )); + +/* Re-checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); + +_exit (_metadata->exit_code); +return ; + } + +EXPECT_EQ (child,waitpid (child, &status,0 )); +EXPECT_EQ (1 ,WIFEXITED (status)); +EXPECT_EQ (EXIT_SUCCESS ,WEXITSTATUS (status)); + +/* Re-checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); +} +TEST_HARNESS_MAIN
tools/testing/selftests/landlock/config +1 -0
@@ -2,6 +2,7 @@ CONFIG_CGROUPS=y CONFIG_CGROUP_SCHED=y CONFIG_INET=y CONFIG_IPV6=y +CONFIG_KEYS=y CONFIG_NET=y CONFIG_NET_NS=y CONFIG_OVERLAY_FS=y
Greg Kroah-Hartman
maintainerPATCH 533/809 landlock: Dont lose track of restrictions on cred_transfer
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 39705a6c29f8a2b93cf5b99528a55366c50014d1 upstream.
When a process' cred struct is replaced, this _almost_ always invokes the cred_prepare LSM hook; but in one special case (when KEYCTL_SESSION_TO_PARENT updates the parent's credentials), the cred_transfer LSM hook is used instead. Landlock only implements the cred_prepare hook, not cred_transfer, so KEYCTL_SESSION_TO_PARENT causes all information on Landlock restrictions to be lost.
This basically means that a process with the ability to use the fork() and keyctl() syscalls can get rid of all Landlock restrictions on itself.
Fix it by adding a cred_transfer hook that does the same thing as the existing cred_prepare hook. (Implemented by having hook_cred_prepare() call hook_cred_transfer() so that the two functions are less likely to accidentally diverge in the future.)
--- security/landlock/cred.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
security/landlock/cred.c +9 -2
@@ -14,8 +14,8 @@#include "ruleset.h" #include "setup.h" -static int hook_cred_prepare (struct cred *const new, -const struct cred *const old,const gfp_t gfp) +static void hook_cred_transfer (struct cred *const new, +const struct cred *const old) {struct landlock_ruleset *const old_dom =landlock_cred (old)->domain;
@@ -23,6 +23,12 @@ static int hook_cred_prepare(struct credlandlock_get_ruleset (old_dom);landlock_cred (new)->domain = old_dom; } +} + +static int hook_cred_prepare (struct cred *const new, +const struct cred *const old,const gfp_t gfp) +{ +hook_cred_transfer (new, old);return 0 ; }
@@ -36,6 +42,7 @@ static void hook_cred_free(struct cred *static struct security_hook_list landlock_hooks[]__ro_after_init = {LSM_HOOK_INIT (cred_prepare, hook_cred_prepare), +LSM_HOOK_INIT (cred_transfer, hook_cred_transfer),LSM_HOOK_INIT (cred_free, hook_cred_free), };
Greg Kroah-Hartman
maintainerPATCH 534/809 mm: huge_memory: use !CONFIG_64BIT to relax huge page alignment on 32 bit machines
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Shi <[email protected]>
commit d9592025000b3cf26c742f3505da7b83aedc26d5 upstream.
Yves-Alexis Perez reported commit 4ef9ad19e176 ("mm: huge_memory: don't force huge page alignment on 32 bit") didn't work for x86_32 [1]. It is because x86_32 uses CONFIG_X86_32 instead of CONFIG_32BIT.
!CONFIG_64BIT should cover all 32 bit machines.
[1] https://lore.kernel.org/linux-mm/CAHbLzkr1LwH3pcTgM+aGQ31ip2bKqiqEQ8=FQB+t2c3dhNKNHA@mail.gmail.com/
--- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/huge_memory.c +1 -1
@@ -857,7 +857,7 @@ static unsigned long __thp_get_unmapped_loff_t off_align =round_up (off, size);unsigned long len_pad, ret, off_sub; -if (IS_ENABLED (CONFIG_32BIT ) ||in_compat_syscall ()) +if (!IS_ENABLED (CONFIG_64BIT ) ||in_compat_syscall ())return 0 ;if (off_end <= off_align || (off_end - off_align) < size)
Re: [PATCH 6.10 534/809] mm: huge_memory: use !CONFIG_64BIT to relax huge page alignment on 32 bit machines
Quoted 12 lines · Greg Kroah-Hartman
6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Shi <[email protected]>
commit
d9592025000b3cf26c742f3505da7b83aedc26d5upstream.Yves-Alexis Perez reported commit
4ef9ad19e176("mm:huge_memory: don't force huge page alignment on 32 bit") didn't work forx86_32[1]. It is becausex86_32usesCONFIG_X86_32instead ofCONFIG_32BIT.
Quoted 6 lines
!CONFIG_64BIT should cover all 32 bit machines.
[1] https://lore.kernel.org/linux-mm/CAHbLzkr1LwH3pcTgM+aGQ31ip2bKqiqEQ8=FQB+t2c3dhNKNHA@mail.gmail.com/
Fixes 4ef9ad19e176 ("mm: huge_memory: don't force huge page alignment on 32 bit")
[...]
The original breakage actually occurred in 5.18 with this commit:
commit 1854bc6e2420472676c5c90d3d6b15f6cd640e40
Author: William Kucharski <[email protected]> Date: Sun Sep 22 08:43:15 2019 -0400
mm/readahead: Align file mappings for non-DAX
The previous fix referred to above (commit 4ef9ad19e176) was already backported to 6.1 and 6.7, and CVE-2024-26621 was assigned to the bug.
This new fix also needs to be applied to 6.1. *Both* fixes need to be applied to 6.6 since the previous fix missed this branch.
I believe a new CVE ID also needs to be assigned to cover the architectures missed in the previous fix. So far as I can see, the only architectures supporting huge pages on 32-bit CPUs (as of 6.11-rc1) are arc, arm, mips, and x86. Of those only mips defines CONFIG_32BIT in 32-bit configurations, and was covered by the previous fix. The other three are covered by the new fix.
To summarise:
CVE-2024-26621:
- covers 64-bit compat and mips32 native
- fixed by commit 4ef9ad19e176
- fix is needed in 6.6
CVE ID to be assigned:
- covers arc, arm, and x86_32 native
- fixed by commit d9592025000b
- fix is needed in 6.1 and 6.6
Ben.
Signature · 2 lines
Ben Hutchings To err is human; to really foul things up requires a computer.
Greg Kroah-Hartman
maintainerRe: [PATCH 6.10 534/809] mm: huge_memory: use !CONFIG_64BIT to relax huge page alignment on 32 bit machines
Quoted 42 lines · Ben Hutchings
Quoted 12 lines · Greg Kroah-Hartman
6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Shi <[email protected]>
commit
d9592025000b3cf26c742f3505da7b83aedc26d5upstream.Yves-Alexis Perez reported commit
4ef9ad19e176("mm:huge_memory: don't force huge page alignment on 32 bit") didn't work forx86_32[1]. It is becausex86_32usesCONFIG_X86_32instead ofCONFIG_32BIT.Quoted 6 lines
!CONFIG_64BIT should cover all 32 bit machines.
[1] https://lore.kernel.org/linux-mm/CAHbLzkr1LwH3pcTgM+aGQ31ip2bKqiqEQ8=FQB+t2c3dhNKNHA@mail.gmail.com/
Fixes 4ef9ad19e176 ("mm: huge_memory: don't force huge page alignment on 32 bit")[...]
The original breakage actually occurred in 5.18 with this commit:
commit
1854bc6e2420472676c5c90d3d6b15f6cd640e40Author: William Kucharski <[email protected]> Date: Sun Sep 22 08:43:15 2019 -0400mm/readahead: Align file mappings for non-DAX
The previous fix referred to above (commit
4ef9ad19e176) was already backported to 6.1 and 6.7, and CVE-2024-26621 was assigned to the bug.This new fix also needs to be applied to 6.1. *Both* fixes need to be applied to 6.6 since the previous fix missed this branch.
I believe a new CVE ID also needs to be assigned to cover the architectures missed in the previous fix. So far as I can see, the only architectures supporting huge pages on 32-bit CPUs (as of 6.11-rc1) are arc, arm, mips, and x86. Of those only mips defines
CONFIG_32BITin 32-bit configurations, and was covered by the previous fix. The other three are covered by the new fix.
Quoted 6 lines
To summarise:
CVE-2024-26621:
- covers 64-bit compat and mips32 native
- fixed by commit4ef9ad19e176
- fix is needed in 6.6
Now queued up for 6.6.y, thanks.
Quoted 4 lines
CVE ID to be assigned:
- covers arc, arm, andx86_32native
- fixed by commitd9592025000b
- fix is needed in 6.1 and 6.6
Now queued up, I'll go assign a CVE now, thanks!
greg k-h
Greg Kroah-Hartman
maintainerPATCH 535/809 mm/huge_memory: avoid PMD-size page cache if needed
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gavin Shan <[email protected]>
commit d659b715e94ac039803d7601505d3473393fc0be upstream.
xarray can't support arbitrary page cache size. the largest and supported page cache size is defined as MAX_PAGECACHE_ORDER by commit 099d90642a71 ("mm/filemap: make MAX_PAGECACHE_ORDER acceptable to xarray"). However, it's possible to have 512MB page cache in the huge memory's collapsing path on ARM64 system whose base page size is 64KB. 512MB page cache is breaking the limitation and a warning is raised when the xarray entry is split as shown in the following example.
[root@dhcp-10-26-1-207 ~]# cat /proc/1/smaps | grep KernelPageSize
KernelPageSize: 64 kB
[root@dhcp-10-26-1-207 ~]# cat /tmp/test.c
:
int main(int argc, char **argv)
{
const char *filename = TEST_XFS_FILENAME;
int fd = 0;
void *buf = (void *)-1, *p;
int pgsize = getpagesize();
int ret = 0;
if (pgsize != 0x10000) {
fprintf(stdout, "System with 64KB base page size is required!\n");
return -EPERM;
}
system("echo 0 > /sys/devices/virtual/bdi/253:0/read_ahead_kb");
system("echo 1 > /proc/sys/vm/drop_caches");
/* Open the xfs file */
fd = open(filename, O_RDONLY);
assert(fd > 0);
/* Create VMA */
buf = mmap(NULL, TEST_MEM_SIZE, PROT_READ, MAP_SHARED, fd, 0);
assert(buf != (void *)-1);
fprintf(stdout, "mapped buffer at 0x%p\n", buf);
/* Populate VMA */
ret = madvise(buf, TEST_MEM_SIZE, MADV_NOHUGEPAGE);
assert(ret == 0);
ret = madvise(buf, TEST_MEM_SIZE, MADV_POPULATE_READ);
assert(ret == 0);
/* Collapse VMA */
ret = madvise(buf, TEST_MEM_SIZE, MADV_HUGEPAGE);
assert(ret == 0);
ret = madvise(buf, TEST_MEM_SIZE, MADV_COLLAPSE);
if (ret) {
fprintf(stdout, "Error %d to madvise(MADV_COLLAPSE)\n", errno);
goto out;
}
/* Split xarray entry. Write permission is needed */
munmap(buf, TEST_MEM_SIZE);
buf = (void *)-1;
close(fd);
fd = open(filename, O_RDWR);
assert(fd > 0);
fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE,
TEST_MEM_SIZE - pgsize, pgsize);
out:
if (buf != (void *)-1)
munmap(buf, TEST_MEM_SIZE);
if (fd > 0)
close(fd);
return ret;
}[root@dhcp-10-26-1-207 ~]# gcc /tmp/test.c -o /tmp/test [root@dhcp-10-26-1-207 ~]# /tmp/test
------------[ cut here ]------------ WARNING: CPU: 25 PID: 7560 at lib/xarray.c:1025 xas_split_alloc+0xf8/0x128 Modules linked in: nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib \ nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct \ nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 \ ip_set rfkill nf_tables nfnetlink vfat fat virtio_balloon drm fuse \ xfs libcrc32c crct10dif_ce ghash_ce sha2_ce sha256_arm64 virtio_net \ sha1_ce net_failover virtio_blk virtio_console failover dimlib virtio_mmio CPU: 25 PID: 7560 Comm: test Kdump: loaded Not tainted 6.10.0-rc7-gavin+ #9 Hardware name: QEMU KVM Virtual Machine, BIOS edk2-20240524-1.el9 05/24/2024 pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--) pc : xas_split_alloc+0xf8/0x128 lr : split_huge_page_to_list_to_order+0x1c4/0x780 sp : ffff8000ac32f660 x29: ffff8000ac32f660 x28: ffff0000e0969eb0 x27: ffff8000ac32f6c0 x26: 0000000000000c40 x25: ffff0000e0969eb0 x24: 000000000000000d x23: ffff8000ac32f6c0 x22: ffffffdfc0700000 x21: 0000000000000000 x20: 0000000000000000 x19: ffffffdfc0700000 x18: 0000000000000000 x17: 0000000000000000 x16: ffffd5f3708ffc70 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 x11: ffffffffffffffc0 x10: 0000000000000040 x9 : ffffd5f3708e692c x8 : 0000000000000003 x7 : 0000000000000000 x6 : ffff0000e0969eb8 x5 : ffffd5f37289e378 x4 : 0000000000000000 x3 : 0000000000000c40 x2 : 000000000000000d x1 : 000000000000000c x0 : 0000000000000000 Call trace: xas_split_alloc+0xf8/0x128 split_huge_page_to_list_to_order+0x1c4/0x780 truncate_inode_partial_folio+0xdc/0x160 truncate_inode_pages_range+0x1b4/0x4a8 truncate_pagecache_range+0x84/0xa0 xfs_flush_unmap_range+0x70/0x90 [xfs] xfs_file_fallocate+0xfc/0x4d8 [xfs] vfs_fallocate+0x124/0x2f0 ksys_fallocate+0x4c/0xa0 __arm64_sys_fallocate+0x24/0x38 invoke_syscall.constprop.0+0x7c/0xd8 do_el0_svc+0xb4/0xd0 el0_svc+0x44/0x1d8 el0t_64_sync_handler+0x134/0x150 el0t_64_sync+0x17c/0x180
Fix it by correcting the supported page cache orders, different sets for DAX and other files. With it corrected, 512MB page cache becomes disallowed on all non-DAX files on ARM64 system where the base page size is 64KB. After this patch is applied, the test program fails with error -EINVAL returned from __thp_vma_allowable_orders() and the madvise() system call to collapse the page caches.
--- include/linux/huge_mm.h | 12 +++++++++--- mm/huge_memory.c | 12 ++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-)
include/linux/huge_mm.h +9 -3
@@ -72,14 +72,20 @@ extern struct kobj_attribute shmem_enabl#define THP_ORDERS_ALL_ANON ((BIT(PMD_ORDER + 1) - 1) & ~(BIT(0) | BIT(1)))/* -* Mask of all large folio orders supported for file THP. +* Mask of all large folio orders supported for file THP. Folios in a DAX +* file is never split and the MAX_PAGECACHE_ORDER limit does not apply to +* it. */ -#define THP_ORDERS_ALL_FILE (BIT(PMD_ORDER) | BIT(PUD_ORDER)) +#define THP_ORDERS_ALL_FILE_DAX \ + (BIT(PMD_ORDER) | BIT(PUD_ORDER)) +#define THP_ORDERS_ALL_FILE_DEFAULT \ + ((BIT(MAX_PAGECACHE_ORDER + 1) - 1) & ~BIT(0))/* * Mask of all large folio orders supported for THP. */ -#define THP_ORDERS_ALL (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE) +#define THP_ORDERS_ALL \ + (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DAX | THP_ORDERS_ALL_FILE_DEFAULT)#define TVA_SMAPS (1 << 0)/* Will be used for procfs */ #define TVA_IN_PF (1 << 1)/* Page fault handler */
mm/huge_memory.c +10 -2
@@ -88,9 +88,17 @@ unsigned long __thp_vma_allowable_ordersbool smaps = tva_flags &TVA_SMAPS ;bool in_pf = tva_flags &TVA_IN_PF ;bool enforce_sysfs = tva_flags &TVA_ENFORCE_SYSFS ; +unsigned long supported_orders; +/* Check the intersection of requested and supported orders. */ - orders &=vma_is_anonymous (vma) ? -THP_ORDERS_ALL_ANON :THP_ORDERS_ALL_FILE ; +if (vma_is_anonymous (vma)) + supported_orders =THP_ORDERS_ALL_ANON ; +else if (vma_is_dax (vma)) + supported_orders =THP_ORDERS_ALL_FILE_DAX ; +else + supported_orders =THP_ORDERS_ALL_FILE_DEFAULT ; + + orders &= supported_orders;if (!orders)return 0 ;
Greg Kroah-Hartman
maintainerPATCH 536/809 hugetlb: force allocating surplus hugepages on mempolicy allowed nodes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aristeu Rozanski <[email protected]>
commit 003af997c8a945493859dd1a2d015cc9387ff27a upstream.
When trying to allocate a hugepage with no reserved ones free, it may be allowed in case a number of overcommit hugepages was configured (using /proc/sys/vm/nr_overcommit_hugepages) and that number wasn't reached. This allows for a behavior of having extra hugepages allocated dynamically, if there're resources for it. Some sysadmins even prefer not reserving any hugepages and setting a big number of overcommit hugepages.
But while attempting to allocate overcommit hugepages in a multi node system (either NUMA or mempolicy/cpuset) said allocations might randomly fail even when there're resources available for the allocation.
This happens due to allowed_mems_nr() only accounting for the number of free hugepages in the nodes the current process belongs to and the surplus hugepage allocation is done so it can be allocated in any node. In case one or more of the requested surplus hugepages are allocated in a different node, the whole allocation will fail due allowed_mems_nr() returning a lower value.
So allocate surplus hugepages in one of the nodes the current process belongs to.
Easy way to reproduce this issue is to use a 2+ NUMA nodes system:
# echo 0 >/proc/sys/vm/nr_hugepages # echo 1 >/proc/sys/vm/nr_overcommit_hugepages # numactl -m0 ./tools/testing/selftests/mm/map_hugetlb 2
Repeating the execution of map_hugetlb test application will eventually fail when the hugepage ends up allocated in a different node.
--- mm/hugetlb.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-)
mm/hugetlb.c +28 -19
@@ -2586,6 +2586,23 @@ struct folio *alloc_hugetlb_folio_nodemareturn alloc_migrate_hugetlb_folio (h, gfp_mask, preferred_nid, nmask); } +static nodemask_t *policy_mbind_nodemask (gfp_t gfp) +{ +#ifdef CONFIG_NUMA +struct mempolicy *mpol =get_task_policy (current); + +/* +* Only enforce MPOL_BIND policy which overlaps with cpuset policy +* (from policy_nodemask) specifically for hugetlb case +*/ +if (mpol->mode ==MPOL_BIND && + (apply_policy_zone (mpol,gfp_zone (gfp)) && +cpuset_nodemask_valid_mems_allowed (&mpol->nodes))) +return &mpol->nodes; +#endif +return NULL ; +} +/* * Increase the hugetlb pool such that it can accommodate a reservation * of size 'delta'.
@@ -2599,6 +2616,8 @@ static int gather_surplus_pages(struct hlong i;long needed, allocated;bool alloc_ok = true; +int node; +nodemask_t *mbind_nodemask =policy_mbind_nodemask (htlb_alloc_mask (h));lockdep_assert_held (&hugetlb_lock); needed = (h->resv_huge_pages + delta) - h->free_huge_pages;
@@ -2613,8 +2632,15 @@ static int gather_surplus_pages(struct h retry:spin_unlock_irq (&hugetlb_lock);for (i =0 ; i < needed; i++) { - folio =alloc_surplus_hugetlb_folio (h,htlb_alloc_mask (h), -NUMA_NO_NODE ,NULL ); + folio =NULL ; +for_each_node_mask (node, cpuset_current_mems_allowed) { +if (!mbind_nodemask ||node_isset (node, *mbind_nodemask)) { + folio =alloc_surplus_hugetlb_folio (h,htlb_alloc_mask (h), + node,NULL ); +if (folio) +break ; + } + }if (!folio) { alloc_ok = false;break ;
@@ -4840,23 +4866,6 @@ static int __init default_hugepagesz_set }__setup ("default_hugepagesz=" , default_hugepagesz_setup); -static nodemask_t *policy_mbind_nodemask (gfp_t gfp) -{ -#ifdef CONFIG_NUMA -struct mempolicy *mpol =get_task_policy (current); - -/* -* Only enforce MPOL_BIND policy which overlaps with cpuset policy -* (from policy_nodemask) specifically for hugetlb case -*/ -if (mpol->mode ==MPOL_BIND && - (apply_policy_zone (mpol,gfp_zone (gfp)) && -cpuset_nodemask_valid_mems_allowed (&mpol->nodes))) -return &mpol->nodes; -#endif -return NULL ; -} -static unsigned int allowed_mems_nr (struct hstate *h) {int node;
Greg Kroah-Hartman
maintainerPATCH 537/809 mm/hugetlb: fix possible recursive locking detected warning
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaohe Lin <[email protected]>
commit 667574e873b5f77a220b2a93329689f36fb56d5d upstream.
When tries to demote 1G hugetlb folios, a lockdep warning is observed:
============================================
WARNING: possible recursive locking detected 6.10.0-rc6-00452-ga4d0275fa660-dirty #79 Not tainted
--------------------------------------------
bash/710 is trying to acquire lock:ffffffff8f0a7850 (&h->resize_lock){+.+.}-{3:3}, at: demote_store+0x244/0x460
but task is already holding lock:ffffffff8f0a6f48 (&h->resize_lock){+.+.}-{3:3}, at: demote_store+0xae/0x460
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&h->resize_lock);
lock(&h->resize_lock);
*** DEADLOCK ***
May be due to missing lock nesting notation
4 locks held by bash/710:
#0: ffff8f118439c3f0 (sb_writers#5){.+.+}-{0:0}, at: ksys_write+0x64/0xe0 #1: ffff8f11893b9e88 (&of->mutex#2){+.+.}-{3:3}, at: kernfs_fop_write_iter+0xf8/0x1d0 #2: ffff8f1183dc4428 (kn->active#98){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x100/0x1d0 #3: ffffffff8f0a6f48 (&h->resize_lock){+.+.}-{3:3}, at: demote_store+0xae/0x460
stack backtrace: CPU: 3 PID: 710 Comm: bash Not tainted 6.10.0-rc6-00452-ga4d0275fa660-dirty #79 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x68/0xa0 __lock_acquire+0x10f2/0x1ca0 lock_acquire+0xbe/0x2d0 __mutex_lock+0x6d/0x400 demote_store+0x244/0x460 kernfs_fop_write_iter+0x12c/0x1d0 vfs_write+0x380/0x540 ksys_write+0x64/0xe0 do_syscall_64+0xb9/0x1d0 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fa61db14887 RSP: 002b:00007ffc56c48358 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fa61db14887 RDX: 0000000000000002 RSI: 000055a030050220 RDI: 0000000000000001 RBP: 000055a030050220 R08: 00007fa61dbd1460 R09: 000000007fffffff R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002 R13: 00007fa61dc1b780 R14: 00007fa61dc17600 R15: 00007fa61dc16a00 </TASK>
Lockdep considers this an AA deadlock because the different resize_lock mutexes reside in the same lockdep class, but this is a false positive. Place them in distinct classes to avoid these warnings.
--- include/linux/hugetlb.h | 1 + mm/hugetlb.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
include/linux/hugetlb.h +1 -0
@@ -681,6 +681,7 @@ HPAGEFLAG(RawHwpUnreliable, raw_hwp_unre/* Defines one hugetlb page size */ struct hstate {struct mutex resize_lock; +struct lock_class_key resize_key;int next_nid_to_alloc;int next_nid_to_free;unsigned int order;
mm/hugetlb.c +1 -1
@@ -4643,7 +4643,7 @@ void __init hugetlb_add_hstate(unsignedBUG_ON (hugetlb_max_hstate >=HUGE_MAX_HSTATE );BUG_ON (order <order_base_2 (__NR_USED_SUBPAGE)); h = &hstates[hugetlb_max_hstate++]; -mutex_init (&h->resize_lock); +__mutex_init (&h->resize_lock,"resize mutex" , &h->resize_key); h->order = order; h->mask = ~(huge_page_size (h) -1 );for (i =0 ; i <MAX_NUMNODES ; ++i)
Greg Kroah-Hartman
maintainerPATCH 538/809 mm/mglru: fix div-by-zero in vmpressure_calc_level()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 8b671fe1a879923ecfb72dda6caf01460dd885ef upstream.
evict_folios() uses a second pass to reclaim folios that have gone through page writeback and become clean before it finishes the first pass, since folio_rotate_reclaimable() cannot handle those folios due to the isolation.
The second pass tries to avoid potential double counting by deducting scan_control->nr_scanned. However, this can result in underflow of nr_scanned, under a condition where shrink_folio_list() does not increment nr_scanned, i.e., when folio_trylock() fails.
The underflow can cause the divisor, i.e., scale=scanned+reclaimed in vmpressure_calc_level(), to become zero, resulting in the following crash:
[exception RIP: vmpressure_work_fn+101]
process_one_work at ffffffffa3313f2b
Since scan_control->nr_scanned has no established semantics, the potential double counting has minimal risks. Therefore, fix the problem by not deducting scan_control->nr_scanned in evict_folios().
--- mm/vmscan.c | 1 - 1 file changed, 1 deletion(-)
mm/vmscan.c +0 -1
@@ -4582,7 +4582,6 @@ retry:/* retry folios that may have missed folio_rotate_reclaimable() */ list_move (&folio->lru, &clean); - sc->nr_scanned -=folio_nr_pages (folio); }spin_lock_irq (&lruvec->lru_lock);
Greg Kroah-Hartman
maintainerPATCH 539/809 mm: mmap_lock: replace get_memcg_path_buf() with on-stack buffer
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
commit 7d6be67cfdd4a53cea7147313ca13c531e3a470f upstream.
Commit 2b5067a8143e ("mm: mmap_lock: add tracepoints around lock acquisition") introduced TRACE_MMAP_LOCK_EVENT() macro using preempt_disable() in order to let get_mm_memcg_path() return a percpu buffer exclusively used by normal, softirq, irq and NMI contexts respectively.
Commit 832b50725373 ("mm: mmap_lock: use local locks instead of disabling preemption") replaced preempt_disable() with local_lock(&memcg_paths.lock) based on an argument that preempt_disable() has to be avoided because get_mm_memcg_path() might sleep if PREEMPT_RT=y.
But syzbot started reporting
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
and
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
messages, for local_lock() does not disable IRQ.
We could replace local_lock() with local_lock_irqsave() in order to suppress these messages. But this patch instead replaces percpu buffers with on-stack buffer, for the size of each buffer returned by get_memcg_path_buf() is only 256 bytes which is tolerable for allocating from current thread's kernel stack memory.
--- mm/mmap_lock.c | 175 ++++++--------------------------------------------------- 1 file changed, 20 insertions(+), 155 deletions(-)
mm/mmap_lock.c +20 -155
@@ -19,14 +19,7 @@ EXPORT_TRACEPOINT_SYMBOL(mmap_lock_relea#ifdef CONFIG_MEMCG -/* -* Our various events all share the same buffer (because we don't want or need -* to allocate a set of buffers *per event type*), so we need to protect against -* concurrent _reg() and _unreg() calls, and count how many _reg() calls have -* been made. -*/ -static DEFINE_MUTEX (reg_lock); -static int reg_refcount;/* Protected by reg_lock. */ +static atomic_t reg_refcount;/* * Size of the buffer for memcg path names. Ignoring stack trace support,
@@ -34,136 +27,22 @@ static int reg_refcount; /* Protected by*/ #define MEMCG_PATH_BUF_SIZE MAX_FILTER_STR_VAL -/* -* How many contexts our trace events might be called in: normal, softirq, irq, -* and NMI. -*/ -#define CONTEXT_COUNT 4 - -struct memcg_path { -local_lock_t lock; -char __rcu *buf; -local_t buf_idx; -}; -static DEFINE_PER_CPU(struct memcg_path, memcg_paths) = { - .lock =INIT_LOCAL_LOCK (lock), - .buf_idx =LOCAL_INIT (0 ), -}; - -static char **tmp_bufs; - -/* Called with reg_lock held. */ -static void free_memcg_path_bufs (void ) -{ -struct memcg_path *memcg_path; -int cpu; -char **old = tmp_bufs; - -for_each_possible_cpu (cpu) { - memcg_path =per_cpu_ptr (&memcg_paths, cpu); - *(old++) =rcu_dereference_protected (memcg_path->buf, -lockdep_is_held (®_lock)); -rcu_assign_pointer (memcg_path->buf,NULL ); - } - -/* Wait for inflight memcg_path_buf users to finish. */ -synchronize_rcu (); - - old = tmp_bufs; -for_each_possible_cpu (cpu) { -kfree (*(old++)); - } - -kfree (tmp_bufs); - tmp_bufs =NULL ; -} -int trace_mmap_lock_reg (void ) { -int cpu; -char *new; - -mutex_lock (®_lock); - -/* If the refcount is going 0->1, proceed with allocating buffers. */ -if (reg_refcount++) - goto out; - - tmp_bufs =kmalloc_array (num_possible_cpus (),sizeof (*tmp_bufs), -GFP_KERNEL ); -if (tmp_bufs ==NULL ) - goto out_fail; - -for_each_possible_cpu (cpu) { - new =kmalloc (MEMCG_PATH_BUF_SIZE *CONTEXT_COUNT ,GFP_KERNEL ); -if (new ==NULL ) - goto out_fail_free; -rcu_assign_pointer (per_cpu_ptr (&memcg_paths, cpu)->buf, new); -/* Don't need to wait for inflights, they'd have gotten NULL. */ - } - -out: -mutex_unlock (®_lock); +atomic_inc (®_refcount);return 0 ; - -out_fail_free: -free_memcg_path_bufs (); -out_fail: -/* Since we failed, undo the earlier ref increment. */ - --reg_refcount; - -mutex_unlock (®_lock); -return -ENOMEM ; }void trace_mmap_lock_unreg (void ) { -mutex_lock (®_lock); - -/* If the refcount is going 1->0, proceed with freeing buffers. */ -if (--reg_refcount) - goto out; - -free_memcg_path_bufs (); - -out: -mutex_unlock (®_lock); -} - -static inline char *get_memcg_path_buf (void ) -{ -struct memcg_path *memcg_path =this_cpu_ptr (&memcg_paths); -char *buf; -int idx; - -rcu_read_lock (); - buf =rcu_dereference (memcg_path->buf); -if (buf ==NULL ) { -rcu_read_unlock (); -return NULL ; - } - idx =local_add_return (MEMCG_PATH_BUF_SIZE , &memcg_path->buf_idx) - -MEMCG_PATH_BUF_SIZE ; -return &buf[idx]; +atomic_dec (®_refcount); } -static inline void put_memcg_path_buf (void ) -{ -local_sub (MEMCG_PATH_BUF_SIZE , &this_cpu_ptr (&memcg_paths)->buf_idx); -rcu_read_unlock (); -} - -#define TRACE_MMAP_LOCK_EVENT (type, mm, ...) \ - do { \ - const char *memcg_path; \ - local_lock(&memcg_paths.lock); \ - memcg_path = get_mm_memcg_path(mm); \ - trace_mmap_lock_##type(mm, \ - memcg_path != NULL ? memcg_path : "", \ - ##__VA_ARGS__); \ - if (likely(memcg_path != NULL)) \ - put_memcg_path_buf(); \ - local_unlock(&memcg_paths.lock); \ +#define TRACE_MMAP_LOCK_EVENT (type, mm, ...) \ + do { \ + char buf[MEMCG_PATH_BUF_SIZE]; \ + get_mm_memcg_path(mm, buf, sizeof(buf)); \ + trace_mmap_lock_##type(mm, buf, ##__VA_ARGS__); \ } while (0)#else /* !CONFIG_MEMCG */
@@ -185,37 +64,23 @@ void trace_mmap_lock_unreg(void)#ifdef CONFIG_TRACING #ifdef CONFIG_MEMCG /* -* Write the given mm_struct's memcg path to a percpu buffer, and return a -* pointer to it. If the path cannot be determined, or no buffer was available -* (because the trace event is being unregistered), NULL is returned. -* -* Note: buffers are allocated per-cpu to avoid locking, so preemption must be -* disabled by the caller before calling us, and re-enabled only after the -* caller is done with the pointer. -* -* The caller must call put_memcg_path_buf() once the buffer is no longer -* needed. This must be done while preemption is still disabled. +* Write the given mm_struct's memcg path to a buffer. If the path cannot be +* determined or the trace event is being unregistered, empty string is written. */ -static const char *get_mm_memcg_path (struct mm_struct *mm) +static void get_mm_memcg_path (struct mm_struct *mm,char *buf,size_t buflen) { -char *buf =NULL ; -struct mem_cgroup *memcg =get_mem_cgroup_from_mm (mm); +struct mem_cgroup *memcg; + buf[0 ] ='\0' ; +/* No need to get path if no trace event is registered. */ +if (!atomic_read (®_refcount)) +return ; + memcg =get_mem_cgroup_from_mm (mm);if (memcg ==NULL ) - goto out; -if (unlikely (memcg->css.cgroup ==NULL )) - goto out_put; - - buf =get_memcg_path_buf (); -if (buf ==NULL ) - goto out_put; - -cgroup_path (memcg->css.cgroup, buf,MEMCG_PATH_BUF_SIZE ); - -out_put: +return ; +if (memcg->css.cgroup) +cgroup_path (memcg->css.cgroup, buf, buflen);css_put (&memcg->css); -out: -return buf; }#endif /* CONFIG_MEMCG */
Greg Kroah-Hartman
maintainerPATCH 540/809 mm/mglru: fix overshooting shrinker memory
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 3f74e6bd3b84a8b6bb3cc51609c89e5b9d58eed7 upstream.
set_initial_priority() tries to jump-start global reclaim by estimating the priority based on cold/hot LRU pages. The estimation does not account for shrinker objects, and it cannot do so because their sizes can be in different units other than page.
If shrinker objects are the majority, e.g., on TrueNAS SCALE 24.04.0 where ZFS ARC can use almost all system memory, set_initial_priority() can vastly underestimate how much memory ARC shrinker can evict and assign extreme low values to scan_control->priority, resulting in overshoots of shrinker objects.
To reproduce the problem, using TrueNAS SCALE 24.04.0 with 32GB DRAM, a test ZFS pool and the following commands:
fio --name=mglru.file --numjobs=36 --ioengine=io_uring \
--directory=/root/test-zfs-pool/ --size=1024m --buffered=1 \
--rw=randread --random_distribution=random \
--time_based --runtime=1h &
for ((i = 0; i < 20; i++))
do
sleep 120
fio --name=mglru.anon --numjobs=16 --ioengine=mmap \
--filename=/dev/zero --size=1024m --fadvise_hint=0 \
--rw=randrw --random_distribution=random \
--time_based --runtime=1m
doneTo fix the problem:
1. Cap scan_control->priority at or above DEF_PRIORITY/2, to prevent the jump-start from being overly aggressive.
2. Account for the progress from mm_account_reclaimed_pages(), to prevent kswapd_shrink_node() from raising the priority unnecessarily.
--- mm/vmscan.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
mm/vmscan.c +8 -2
@@ -4915,7 +4915,11 @@ static void set_initial_priority(struct/* round down reclaimable and round up sc->nr_to_reclaim */ priority =fls_long (reclaimable) -1 -fls_long (sc->nr_to_reclaim -1 ); - sc->priority =clamp (priority,0 ,DEF_PRIORITY ); +/* +* The estimation is based on LRU pages only, so cap it to prevent +* overshoots of shrinker objects by large margins. +*/ + sc->priority =clamp (priority,DEF_PRIORITY /2 ,DEF_PRIORITY ); }static void lru_gen_shrink_node (struct pglist_data *pgdat,struct scan_control *sc)
@@ -6701,6 +6705,7 @@ static bool kswapd_shrink_node(pg_data_t {struct zone *zone;int z; +unsigned long nr_reclaimed = sc->nr_reclaimed;/* Reclaim a number of pages proportional to the number of zones */ sc->nr_to_reclaim =0 ;
@@ -6728,7 +6733,8 @@ static bool kswapd_shrink_node(pg_data_tif (sc->order && sc->nr_reclaimed >=compact_gap (sc->order)) sc->order =0 ; -return sc->nr_scanned >= sc->nr_to_reclaim; +/* account for progress from mm_account_reclaimed_pages() */ +return max (sc->nr_scanned, sc->nr_reclaimed - nr_reclaimed) >= sc->nr_to_reclaim; }/* Page allocator PCP high watermark is lowered if reclaim is active. */
Greg Kroah-Hartman
maintainerPATCH 541/809 mm/mglru: fix ineffective protection calculation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 30d77b7eef019fa4422980806e8b7cdc8674493e upstream.
mem_cgroup_calculate_protection() is not stateless and should only be used as part of a top-down tree traversal. shrink_one() traverses the per-node memcg LRU instead of the root_mem_cgroup tree, and therefore it should not call mem_cgroup_calculate_protection().
The existing misuse in shrink_one() can cause ineffective protection of sub-trees that are grandchildren of root_mem_cgroup. Fix it by reusing lru_gen_age_node(), which already traverses the root_mem_cgroup tree, to calculate the protection.
Previously lru_gen_age_node() opportunistically skips the first pass, i.e., when scan_control->priority is DEF_PRIORITY. On the second pass, lruvec_is_sizable() uses appropriate scan_control->priority, set by set_initial_priority() from lru_gen_shrink_node(), to decide whether a memcg is too small to reclaim from.
Now lru_gen_age_node() unconditionally traverses the root_mem_cgroup tree. So it should call set_initial_priority() upfront, to make sure lruvec_is_sizable() uses appropriate scan_control->priority on the first pass. Otherwise, lruvec_is_reclaimable() can return false negatives and result in premature OOM kills when min_ttl_ms is used.
--- mm/vmscan.c | 82 +++++++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 44 deletions(-)
mm/vmscan.c +38 -44
@@ -3900,6 +3900,32 @@ done:* working set protection ******************************************************************************/ +static void set_initial_priority (struct pglist_data *pgdat,struct scan_control *sc) +{ +int priority; +unsigned long reclaimable; + +if (sc->priority !=DEF_PRIORITY || sc->nr_to_reclaim <MIN_LRU_BATCH ) +return ; +/* +* Determine the initial priority based on +* (total >> priority) * reclaimed_to_scanned_ratio = nr_to_reclaim, +* where reclaimed_to_scanned_ratio = inactive / total. +*/ + reclaimable =node_page_state (pgdat,NR_INACTIVE_FILE ); +if (can_reclaim_anon_pages (NULL , pgdat->node_id, sc)) + reclaimable +=node_page_state (pgdat,NR_INACTIVE_ANON ); + +/* round down reclaimable and round up sc->nr_to_reclaim */ + priority =fls_long (reclaimable) -1 -fls_long (sc->nr_to_reclaim -1 ); + +/* +* The estimation is based on LRU pages only, so cap it to prevent +* overshoots of shrinker objects by large margins. +*/ + sc->priority =clamp (priority,DEF_PRIORITY /2 ,DEF_PRIORITY ); +} +static bool lruvec_is_sizable (struct lruvec *lruvec,struct scan_control *sc) {int gen, type, zone;
@@ -3933,19 +3959,17 @@ static bool lruvec_is_reclaimable(structstruct mem_cgroup *memcg =lruvec_memcg (lruvec);DEFINE_MIN_SEQ (lruvec); -/* see the comment on lru_gen_folio */ - gen =lru_gen_from_seq (min_seq[LRU_GEN_FILE ]); - birth =READ_ONCE (lruvec->lrugen.timestamps[gen]); - -if (time_is_after_jiffies (birth + min_ttl)) +if (mem_cgroup_below_min (NULL , memcg))return false;if (!lruvec_is_sizable (lruvec, sc))return false; -mem_cgroup_calculate_protection (NULL , memcg); +/* see the comment on lru_gen_folio */ + gen =lru_gen_from_seq (min_seq[LRU_GEN_FILE ]); + birth =READ_ONCE (lruvec->lrugen.timestamps[gen]); -return !mem_cgroup_below_min (NULL , memcg); +return time_is_before_jiffies (birth + min_ttl); }/* to protect the working set of the last N jiffies */
@@ -3955,23 +3979,20 @@ static void lru_gen_age_node(struct pgli {struct mem_cgroup *memcg;unsigned long min_ttl =READ_ONCE (lru_gen_min_ttl); +bool reclaimable = !min_ttl;VM_WARN_ON_ONCE (!current_is_kswapd ()); -/* check the order to exclude compaction-induced reclaim */ -if (!min_ttl || sc->order || sc->priority ==DEF_PRIORITY ) -return ; +set_initial_priority (pgdat, sc); memcg =mem_cgroup_iter (NULL ,NULL ,NULL );do {struct lruvec *lruvec =mem_cgroup_lruvec (memcg, pgdat); -if (lruvec_is_reclaimable (lruvec, sc, min_ttl)) { -mem_cgroup_iter_break (NULL , memcg); -return ; - } +mem_cgroup_calculate_protection (NULL , memcg); -cond_resched (); +if (!reclaimable) + reclaimable =lruvec_is_reclaimable (lruvec, sc, min_ttl); }while ((memcg =mem_cgroup_iter (NULL , memcg,NULL )));/*
@@ -3979,7 +4000,7 @@ static void lru_gen_age_node(struct pgli* younger than min_ttl. However, another possibility is all memcgs are * either too small or below min. */ -if (mutex_trylock (&oom_lock)) { +if (!reclaimable &&mutex_trylock (&oom_lock)) {struct oom_control oc = { .gfp_mask = sc->gfp_mask, };
@@ -4771,8 +4792,7 @@ static int shrink_one(struct lruvec *lrustruct mem_cgroup *memcg =lruvec_memcg (lruvec);struct pglist_data *pgdat =lruvec_pgdat (lruvec); -mem_cgroup_calculate_protection (NULL , memcg); - +/* lru_gen_age_node() called mem_cgroup_calculate_protection() */ if (mem_cgroup_below_min (NULL , memcg))return MEMCG_LRU_YOUNG ;
@@ -4896,32 +4916,6 @@ static void lru_gen_shrink_lruvec(structblk_finish_plug (&plug); } -static void set_initial_priority (struct pglist_data *pgdat,struct scan_control *sc) -{ -int priority; -unsigned long reclaimable; - -if (sc->priority !=DEF_PRIORITY || sc->nr_to_reclaim <MIN_LRU_BATCH ) -return ; -/* -* Determine the initial priority based on -* (total >> priority) * reclaimed_to_scanned_ratio = nr_to_reclaim, -* where reclaimed_to_scanned_ratio = inactive / total. -*/ - reclaimable =node_page_state (pgdat,NR_INACTIVE_FILE ); -if (can_reclaim_anon_pages (NULL , pgdat->node_id, sc)) - reclaimable +=node_page_state (pgdat,NR_INACTIVE_ANON ); - -/* round down reclaimable and round up sc->nr_to_reclaim */ - priority =fls_long (reclaimable) -1 -fls_long (sc->nr_to_reclaim -1 ); - -/* -* The estimation is based on LRU pages only, so cap it to prevent -* overshoots of shrinker objects by large margins. -*/ - sc->priority =clamp (priority,DEF_PRIORITY /2 ,DEF_PRIORITY ); -} -static void lru_gen_shrink_node (struct pglist_data *pgdat,struct scan_control *sc) {struct blk_plug plug;
Greg Kroah-Hartman
maintainerPATCH 542/809 x86/efistub: Avoid returning EFI_SUCCESS on error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit fb318ca0a522295edd6d796fb987e99ec41f0ee5 upstream.
The fail label is only used in a situation where the previous EFI API call succeeded, and so status will be set to EFI_SUCCESS. Fix this, by dropping the goto entirely, and call efi_exit() with the correct error code.
--- drivers/firmware/efi/libstub/x86-stub.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/firmware/efi/libstub/x86-stub.c +1 -4
@@ -501,16 +501,13 @@ efi_status_t __efiapi efi_pe_entry(efi_h/* Convert unicode cmdline to ascii */ cmdline_ptr =efi_convert_cmdline (image, &options_size);if (!cmdline_ptr) - goto fail; +efi_exit (handle,EFI_OUT_OF_RESOURCES );efi_set_u64_split ((unsigned long )cmdline_ptr, &hdr->cmd_line_ptr, &boot_params.ext_cmd_line_ptr);efi_stub_entry (handle, sys_table_arg, &boot_params);/* not reached */ - -fail: -efi_exit (handle, status); } static void add_e820ext(struct boot_params *params,
Greg Kroah-Hartman
maintainerPATCH 543/809 x86/efistub: Revert to heap allocated boot_params for PE entrypoint
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit ae835a96d72cd025421910edb0e8faf706998727 upstream.
This is a partial revert of commit
8117961d98f ("x86/efi: Disregard setup header of loaded image")
which triggers boot issues on older Dell laptops. As it turns out, switching back to a heap allocation for the struct boot_params constructed by the EFI stub works around this, even though it is unclear why.
--- drivers/firmware/efi/libstub/x86-stub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/firmware/efi/libstub/x86-stub.c +15 -5
@@ -469,11 +469,12 @@ void __noreturn efi_stub_entry(efi_handl efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,efi_system_table_t *sys_table_arg) { - static struct boot_params boot_params __page_aligned_bss; -struct setup_header *hdr = &boot_params.hdr;efi_guid_t proto =LOADED_IMAGE_PROTOCOL_GUID ; +struct boot_params *boot_params; +struct setup_header *hdr;int options_size =0 ;efi_status_t status; +unsigned long alloc;char *cmdline_ptr;if (efi_is_native ())
@@ -491,6 +492,13 @@ efi_status_t __efiapi efi_pe_entry(efi_hefi_exit (handle, status); } + status =efi_allocate_pages (PARAM_SIZE , &alloc,ULONG_MAX ); +if (status !=EFI_SUCCESS ) +efi_exit (handle, status); + + boot_params =memset ((void *)alloc,0x0 ,PARAM_SIZE ); + hdr = &boot_params->hdr; +/* Assign the setup_header fields that the kernel actually cares about */ hdr->root_flags =1 ; hdr->vid_mode =0xffff ;
@@ -500,13 +508,15 @@ efi_status_t __efiapi efi_pe_entry(efi_h/* Convert unicode cmdline to ascii */ cmdline_ptr =efi_convert_cmdline (image, &options_size); -if (!cmdline_ptr) +if (!cmdline_ptr) { +efi_free (PARAM_SIZE , alloc);efi_exit (handle,EFI_OUT_OF_RESOURCES ); + }efi_set_u64_split ((unsigned long )cmdline_ptr, &hdr->cmd_line_ptr, - &boot_params.ext_cmd_line_ptr); + &boot_params->ext_cmd_line_ptr); -efi_stub_entry (handle, sys_table_arg, &boot_params); +efi_stub_entry (handle, sys_table_arg, boot_params);/* not reached */ }
Greg Kroah-Hartman
maintainerPATCH 544/809 Revert "firewire: Annotate struct fw_iso_packet with __counted_by()"
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
commit 00e3913b0416fe69d28745c0a2a340e2f76c219c upstream.
This reverts commit d3155742db89df3b3c96da383c400e6ff4d23c25.
The header_length field is byte unit, thus it can not express the number of elements in header field. It seems that the argument for counted_by attribute can have no arithmetic expression, therefore this commit just reverts the issued commit.
--- include/linux/firewire.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/firewire.h +2 -3
@@ -462,9 +462,8 @@ struct fw_iso_packet {/* rx: Sync bit, wait for matching sy */ u32 tag:2; /* tx: Tag in packet header */ u32 sy:4; /* tx: Sy in packet header */ - u32 header_length:8; /* Length of immediate header */ -/* tx: Top of 1394 isoch. data_block */ - u32 header[] __counted_by(header_length); + u32 header_length:8; /* Size of immediate header */ +u32 header[];/* tx: Top of 1394 isoch. data_block */ };#define FW_ISO_CONTEXT_TRANSMIT 0
Greg Kroah-Hartman
maintainerPATCH 545/809 exfat: fix potential deadlock on __exfat_get_dentry_set
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sungjong Seo <[email protected]>
commit 89fc548767a2155231128cb98726d6d2ea1256c9 upstream.
When accessing a file with more entries than ES_MAX_ENTRY_NUM, the bh-array is allocated in __exfat_get_entry_set. The problem is that the bh-array is allocated with GFP_KERNEL. It does not make sense. In the following cases, a deadlock for sbi->s_lock between the two processes may occur.
CPU0 CPU1
---- ----
kswapd
balance_pgdat
lock(fs_reclaim)
exfat_iterate
lock(&sbi->s_lock)
exfat_readdir
exfat_get_uniname_from_ext_entry
exfat_get_dentry_set
__exfat_get_dentry_set
kmalloc_array
...
lock(fs_reclaim)
...
evict
exfat_evict_inode
lock(&sbi->s_lock)To fix this, let's allocate bh-array with GFP_NOFS.
--- fs/exfat/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/dir.c +1 -1
@@ -813,7 +813,7 @@ static int __exfat_get_dentry_set(struct num_bh =EXFAT_B_TO_BLK_ROUND_UP (off + num_entries *DENTRY_SIZE , sb);if (num_bh >ARRAY_SIZE (es->__bh)) { - es->bh =kmalloc_array (num_bh,sizeof (*es->bh),GFP_KERNEL ); + es->bh =kmalloc_array (num_bh,sizeof (*es->bh),GFP_NOFS );if (!es->bh) {brelse (bh);return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 546/809 thermal/drivers/broadcom: Fix race between removal and clock disable
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit e90c369cc2ffcf7145a46448de101f715a1f5584 upstream.
During the probe, driver enables clocks necessary to access registers (in get_temp()) and then registers thermal zone with managed-resources (devm) interface. Removal of device is not done in reversed order, because:
1. Clock will be disabled in driver remove() callback - thermal zone is still registered and accessible to users,
2. devm interface will unregister thermal zone.
This leaves short window between (1) and (2) for accessing the get_temp() callback with disabled clock.
Fix this by enabling clock also via devm-interface, so entire cleanup path will be in proper, reversed order.
--- drivers/thermal/broadcom/bcm2835_thermal.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/thermal/broadcom/bcm2835_thermal.c +4 -15
@@ -185,7 +185,7 @@ static int bcm2835_thermal_probe(structreturn err; } - data->clk =devm_clk_get (&pdev->dev,NULL ); + data->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (data->clk)) { err =PTR_ERR (data->clk);if (err != -EPROBE_DEFER )
@@ -193,10 +193,6 @@ static int bcm2835_thermal_probe(structreturn err; } - err =clk_prepare_enable (data->clk); -if (err) -return err; - rate =clk_get_rate (data->clk);if ((rate <1920000 ) || (rate >5000000 )) dev_warn(&pdev->dev,
@@ -211,7 +207,7 @@ static int bcm2835_thermal_probe(structdev_err (&pdev->dev,"Failed to register the thermal device: %d\n" , err); - goto err_clk; +return err; }/*
@@ -236,7 +232,7 @@ static int bcm2835_thermal_probe(structdev_err (&pdev->dev,"Not able to read trip_temp: %d\n" , err); - goto err_tz; +return err; }/* set bandgap reference voltage and enable voltage regulator */
@@ -269,17 +265,11 @@ static int bcm2835_thermal_probe(struct*/ err =thermal_add_hwmon_sysfs (tz);if (err) - goto err_tz; +return err;bcm2835_thermal_debugfs (pdev);return 0 ; -err_tz: -devm_thermal_of_zone_unregister (&pdev->dev, tz); -err_clk: -clk_disable_unprepare (data->clk); - -return err; }static void bcm2835_thermal_remove (struct platform_device *pdev)
@@ -287,7 +277,6 @@ static void bcm2835_thermal_remove(strucstruct bcm2835_thermal_data *data =platform_get_drvdata (pdev);debugfs_remove_recursive (data->debugfsdir); -clk_disable_unprepare (data->clk); }static struct platform_driver bcm2835_thermal_driver = {
Greg Kroah-Hartman
maintainerPATCH 547/809 dt-bindings: thermal: correct thermal zone node name limit
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 97e32381d0fc6c2602a767b0c46e15eb2b75971d upstream.
Linux kernel uses thermal zone node name during registering thermal zones and has a hard-coded limit of 20 characters, including terminating NUL byte. The bindings expect node names to finish with '-thermal' which is eight bytes long, thus we have only 11 characters for the reset of the node name (thus 10 for the pattern after leading fixed character).
--- Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +4 -1
@@ -49,7 +49,10 @@ properties: to take when the temperature crosses those thresholds. patternProperties: - "^[a-zA-Z][a-zA-Z0-9\\-]{1,12}-thermal$": + # Node name is limited in size due to Linux kernel requirements - 19 + # characters in total (see THERMAL_NAME_LENGTH, including terminating NUL + # byte): + "^[a-zA-Z][a-zA-Z0-9\\-]{1,10}-thermal$": type: object description: Each thermal zone node contains information about how frequently it
Greg Kroah-Hartman
maintainerPATCH 548/809 tick/broadcast: Make takeover of broadcast hrtimer reliable
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Liao <[email protected]>
commit f7d43dd206e7e18c182f200e67a8db8c209907fa upstream.
Running the LTP hotplug stress test on a aarch64 machine results in rcu_sched stall warnings when the broadcast hrtimer was owned by the un-plugged CPU. The issue is the following:
CPU1 (owns the broadcast hrtimer) CPU2
tick_broadcast_enter() // shutdown local timer device broadcast_shutdown_local() ... tick_broadcast_exit() clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT) // timer device is not programmed cpumask_set_cpu(cpu, tick_broadcast_force_mask) initiates offlining of CPU1
take_cpu_down()
/*
* CPU1 shuts down and does not
* send broadcast IPI anymore
*/
takedown_cpu() hotplug_cpu__broadcast_tick_pull() // move broadcast hrtimer to this CPU clockevents_program_event() bc_set_next() hrtimer_start() /* * timer device is not programmed * because only the first expiring * timer will trigger clockevent * device reprogramming */
What happens is that CPU2 exits broadcast mode with force bit set, then the local timer device is not reprogrammed and CPU2 expects to receive the expired event by the broadcast IPI. But this does not happen because CPU1 is offlined by CPU2. CPU switches the clockevent device to ONESHOT state, but does not reprogram the device.
The subsequent reprogramming of the hrtimer broadcast device does not program the clockevent device of CPU2 either because the pending expiry time is already in the past and the CPU expects the event to be delivered. As a consequence all CPUs which wait for a broadcast event to be delivered are stuck forever.
Fix this issue by reprogramming the local timer device if the broadcast force bit of the CPU is set so that the broadcast hrtimer is delivered.
[ tglx: Massage comment and change log. Add Fixes tag ]
--- kernel/time/tick-broadcast.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
kernel/time/tick-broadcast.c +23 -0
@@ -1141,6 +1141,7 @@ void tick_broadcast_switch_to_oneshot(vo#ifdef CONFIG_HOTPLUG_CPU void hotplug_cpu__broadcast_tick_pull (int deadcpu) { +struct tick_device *td =this_cpu_ptr (&tick_cpu_device);struct clock_event_device *bc;unsigned long flags;
@@ -1148,6 +1149,28 @@ void hotplug_cpu__broadcast_tick_pull(in bc = tick_broadcast_device.evtdev;if (bc &&broadcast_needs_cpu (bc, deadcpu)) { +/* +* If the broadcast force bit of the current CPU is set, +* then the current CPU has not yet reprogrammed the local +* timer device to avoid a ping-pong race. See +* ___tick_broadcast_oneshot_control(). +* +* If the broadcast device is hrtimer based then +* programming the broadcast event below does not have any +* effect because the local clockevent device is not +* running and not programmed because the broadcast event +* is not earlier than the pending event of the local clock +* event device. As a consequence all CPUs waiting for a +* broadcast event are stuck forever. +* +* Detect this condition and reprogram the cpu local timer +* device to avoid the starvation. +*/ +if (tick_check_broadcast_expired ()) { +cpumask_clear_cpu (smp_processor_id (), tick_broadcast_force_mask); +tick_program_event (td->evtdev->next_event,1 ); + } +/* This moves the broadcast assignment to this CPU: */ clockevents_program_event (bc, bc->next_event,1 ); }
Greg Kroah-Hartman
maintainerPATCH 549/809 net: netconsole: Disable target before netpoll cleanup
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit 97d9fba9a812cada5484667a46e14a4c976ca330 upstream.
Currently, netconsole cleans up the netpoll structure before disabling the target. This approach can lead to race conditions, as message senders (write_ext_msg() and write_msg()) check if the target is enabled before using netpoll. The sender can validate that the target is enabled, but, the netpoll might be de-allocated already, causing undesired behaviours.
This patch reverses the order of operations:
1. Disable the target
2. Clean up the netpoll structure
This change eliminates the potential race condition, ensuring that no messages are sent through a partially cleaned-up netpoll structure.
--- drivers/net/netconsole.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netconsole.c +1 -1
@@ -974,6 +974,7 @@ restart:/* rtnl_lock already held * we might sleep in __netpoll_cleanup() */ + nt->enabled = false;spin_unlock_irqrestore (&target_list_lock, flags);__netpoll_cleanup (&nt->np);
@@ -981,7 +982,6 @@ restart:spin_lock_irqsave (&target_list_lock, flags);netdev_put (nt->np.dev, &nt->np.dev_tracker); nt->np.dev =NULL ; - nt->enabled = false; stopped = true;netconsole_target_put (nt); goto restart;
Greg Kroah-Hartman
maintainerPATCH 550/809 af_packet: Handle outgoing VLAN packets without hardware offloading
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengen Du <[email protected]>
commit 79eecf631c14e7f4057186570ac20e2cfac3802e upstream.
The issue initially stems from libpcap. The ethertype will be overwritten as the VLAN TPID if the network interface lacks hardware VLAN offloading. In the outbound packet path, if hardware VLAN offloading is unavailable, the VLAN tag is inserted into the payload but then cleared from the sk_buff struct. Consequently, this can lead to a false negative when checking for the presence of a VLAN tag, causing the packet sniffing outcome to lack VLAN tag information (i.e., TCI-TPID). As a result, the packet capturing tool may be unable to parse packets as expected.
The TCI-TPID is missing because the prb_fill_vlan_info() function does not modify the tp_vlan_tci/tp_vlan_tpid values, as the information is in the payload and not in the sk_buff struct. The skb_vlan_tag_present() function only checks vlan_all in the sk_buff struct. In cooked mode, the L2 header is stripped, preventing the packet capturing tool from determining the correct TCI-TPID value. Additionally, the protocol in SLL is incorrect, which means the packet capturing tool cannot parse the L3 header correctly.
--- net/packet/af_packet.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-)
net/packet/af_packet.c +84 -2
@@ -538,6 +538,61 @@ static void *packet_current_frame(structreturn packet_lookup_frame (po, rb, rb->head, status); } +static u16 vlan_get_tci (struct sk_buff *skb,struct net_device *dev) +{ +u8 *skb_orig_data = skb->data; +int skb_orig_len = skb->len; +struct vlan_hdr vhdr, *vh; +unsigned int header_len; + +if (!dev) +return 0 ; + +/* In the SOCK_DGRAM scenario, skb data starts at the network +* protocol, which is after the VLAN headers. The outer VLAN +* header is at the hard_header_len offset in non-variable +* length link layer headers. If it's a VLAN device, the +* min_header_len should be used to exclude the VLAN header +* size. +*/ +if (dev->min_header_len == dev->hard_header_len) + header_len = dev->hard_header_len; +else if (is_vlan_dev (dev)) + header_len = dev->min_header_len; +else +return 0 ; + +skb_push (skb, skb->data -skb_mac_header (skb)); + vh =skb_header_pointer (skb, header_len,sizeof (vhdr), &vhdr); +if (skb_orig_data != skb->data) { + skb->data = skb_orig_data; + skb->len = skb_orig_len; + } +if (unlikely (!vh)) +return 0 ; + +return ntohs (vh->h_vlan_TCI); +} + +static __be16 vlan_get_protocol_dgram (struct sk_buff *skb) +{ +__be16 proto = skb->protocol; + +if (unlikely (eth_type_vlan (proto))) { +u8 *skb_orig_data = skb->data; +int skb_orig_len = skb->len; + +skb_push (skb, skb->data -skb_mac_header (skb)); + proto =__vlan_get_protocol (skb, proto,NULL ); +if (skb_orig_data != skb->data) { + skb->data = skb_orig_data; + skb->len = skb_orig_len; + } + } + +return proto; +} +static void prb_del_retire_blk_timer (struct tpacket_kbdq_core *pkc) {del_timer_sync (&pkc->retire_blk_timer);
@@ -1007,10 +1062,16 @@ static void prb_clear_rxhash(struct tpacstatic void prb_fill_vlan_info (struct tpacket_kbdq_core *pkc,struct tpacket3_hdr *ppd) { + struct packet_sock *po = container_of(pkc, struct packet_sock, rx_ring.prb_bdqc); +if (skb_vlan_tag_present (pkc->skb)) { ppd->hv1.tp_vlan_tci =skb_vlan_tag_get (pkc->skb); ppd->hv1.tp_vlan_tpid =ntohs (pkc->skb->vlan_proto); ppd->tp_status =TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else if (unlikely (po->sk.sk_type ==SOCK_DGRAM &ð_type_vlan (pkc->skb->protocol))) { + ppd->hv1.tp_vlan_tci =vlan_get_tci (pkc->skb, pkc->skb->dev); + ppd->hv1.tp_vlan_tpid =ntohs (pkc->skb->protocol); + ppd->tp_status =TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; }else { ppd->hv1.tp_vlan_tci =0 ; ppd->hv1.tp_vlan_tpid =0 ;
@@ -2428,6 +2489,10 @@ static int tpacket_rcv(struct sk_buff *s h.h2->tp_vlan_tci =skb_vlan_tag_get (skb); h.h2->tp_vlan_tpid =ntohs (skb->vlan_proto); status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else if (unlikely (sk->sk_type ==SOCK_DGRAM &ð_type_vlan (skb->protocol))) { + h.h2->tp_vlan_tci =vlan_get_tci (skb, skb->dev); + h.h2->tp_vlan_tpid =ntohs (skb->protocol); + status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; }else { h.h2->tp_vlan_tci =0 ; h.h2->tp_vlan_tpid =0 ;
@@ -2457,7 +2522,8 @@ static int tpacket_rcv(struct sk_buff *s sll->sll_halen =dev_parse_header (skb, sll->sll_addr); sll->sll_family =AF_PACKET ; sll->sll_hatype = dev->type; - sll->sll_protocol = skb->protocol; + sll->sll_protocol = (sk->sk_type ==SOCK_DGRAM ) ? +vlan_get_protocol_dgram (skb) : skb->protocol; sll->sll_pkttype = skb->pkt_type;if (unlikely (packet_sock_flag (po,PACKET_SOCK_ORIGDEV ))) sll->sll_ifindex = orig_dev->ifindex;
@@ -3482,7 +3548,8 @@ static int packet_recvmsg(struct socket/* Original length was stored in sockaddr_ll fields */ origlen =PACKET_SKB_CB (skb)->sa.origlen; sll->sll_family =AF_PACKET ; - sll->sll_protocol = skb->protocol; + sll->sll_protocol = (sock->type ==SOCK_DGRAM ) ? +vlan_get_protocol_dgram (skb) : skb->protocol; }sock_recv_cmsgs (msg, sk, skb);
@@ -3539,6 +3606,21 @@ static int packet_recvmsg(struct socket aux.tp_vlan_tci =skb_vlan_tag_get (skb); aux.tp_vlan_tpid =ntohs (skb->vlan_proto); aux.tp_status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else if (unlikely (sock->type ==SOCK_DGRAM &ð_type_vlan (skb->protocol))) { +struct sockaddr_ll *sll = &PACKET_SKB_CB (skb)->sa.ll; +struct net_device *dev; + +rcu_read_lock (); + dev =dev_get_by_index_rcu (sock_net (sk), sll->sll_ifindex); +if (dev) { + aux.tp_vlan_tci =vlan_get_tci (skb, dev); + aux.tp_vlan_tpid =ntohs (skb->protocol); + aux.tp_status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else { + aux.tp_vlan_tci =0 ; + aux.tp_vlan_tpid =0 ; + } +rcu_read_unlock (); }else { aux.tp_vlan_tci =0 ; aux.tp_vlan_tpid =0 ;
Greg Kroah-Hartman
maintainerPATCH 551/809 workqueue: Always queue work items to the newest PWQ for order workqueues
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lai Jiangshan <[email protected]>
commit 58629d4871e8eb2c385b16a73a8451669db59f39 upstream.
To ensure non-reentrancy, __queue_work() attempts to enqueue a work item to the pool of the currently executing worker. This is not only unnecessary for an ordered workqueue, where order inherently suggests non-reentrancy, but it could also disrupt the sequence if the item is not enqueued on the newest PWQ.
Just queue it to the newest PWQ and let order management guarantees non-reentrancy.
--- kernel/workqueue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/workqueue.c +5 -1
@@ -2298,9 +2298,13 @@ retry:* If @work was previously on a different pool, it might still be * running there, in which case the work needs to be queued on that * pool to guarantee non-reentrancy. +* +* For ordered workqueue, work items must be queued on the newest pwq +* for accurate order management. Guaranteed order also guarantees +* non-reentrancy. See the comments above unplug_oldest_pwq(). */ last_pool =get_work_pool (work); -if (last_pool && last_pool != pool) { +if (last_pool && last_pool != pool && !(wq->flags & __WQ_ORDERED)) {struct worker *worker;raw_spin_lock (&last_pool->lock);
Greg Kroah-Hartman
maintainerPATCH 552/809 btrfs: fix extent map use-after-free when adding pages to compressed bio
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 8e7860543a94784d744c7ce34b78a2e11beefa5c upstream.
At add_ra_bio_pages() we are accessing the extent map to calculate 'add_size' after we dropped our reference on the extent map, resulting in a use-after-free. Fix this by computing 'add_size' before dropping our extent map reference.
--- fs/btrfs/compression.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/compression.c +1 -1
@@ -514,6 +514,7 @@ static noinline int add_ra_bio_pages(strput_page (page);break ; } + add_size =min (em->start + em->len, page_end +1 ) - cur;free_extent_map (em);if (page->index == end_index) {
@@ -526,7 +527,6 @@ static noinline int add_ra_bio_pages(str } } - add_size =min (em->start + em->len, page_end +1 ) - cur; ret =bio_add_page (orig_bio, page, add_size,offset_in_page (cur));if (ret != add_size) {unlock_extent (tree, cur, page_end,NULL );
Greg Kroah-Hartman
maintainerPATCH 553/809 kernel: rerun task_work while freezing in get_signal()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 943ad0b62e3c21f324c4884caa6cb4a871bca05c upstream.
io_uring can asynchronously add a task_work while the task is getting freezed. TIF_NOTIFY_SIGNAL will prevent the task from sleeping in do_freezer_trap(), and since the get_signal()'s relock loop doesn't retry task_work, the task will spin there not being able to sleep until the freezing is cancelled / the task is killed / etc.
Run task_works in the freezer path. Keep the patch small and simple so it can be easily back ported, but we might need to do some cleaning after and look if there are other places with similar problems.
--- kernel/signal.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/signal.c +8 -0
@@ -2600,6 +2600,14 @@ static void do_freezer_trap(void)spin_unlock_irq (¤t->sighand->siglock);cgroup_enter_frozen ();schedule (); + +/* +* We could've been woken by task_work, run it to clear +* TIF_NOTIFY_SIGNAL. The caller will retry if necessary. +*/ +clear_notify_signal (); +if (unlikely (task_work_pending (current))) +task_work_run (); }static int ptrace_signal (int signr,kernel_siginfo_t *info,enum pid_type type)
Greg Kroah-Hartman
maintainerPATCH 554/809 ipv6: fix source address selection with route leak
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <[email protected]>
commit 252442f2ae317d109ef0b4b39ce0608c09563042 upstream.
By default, an address assigned to the output interface is selected when the source address is not specified. This is problematic when a route, configured in a vrf, uses an interface from another vrf (aka route leak). The original vrf does not own the selected source address.
Let's add a check against the output interface and call the appropriate function to select the source address.
--- include/net/ip6_route.h | 20 ++++++++++++++------ net/ipv6/ip6_output.c | 1 + net/ipv6/route.c | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-)
include/net/ip6_route.h +14 -6
@@ -127,18 +127,26 @@ void rt6_age_exceptions(struct fib6_infostatic inline int ip6_route_get_saddr (struct net *net,struct fib6_info *f6i,const struct in6_addr *daddr, -unsigned int prefs, +unsigned int prefs,int l3mdev_index,struct in6_addr *saddr) { +struct net_device *l3mdev; +struct net_device *dev; +bool same_vrf;int err =0 ; -if (f6i && f6i->fib6_prefsrc.plen) { +rcu_read_lock (); + + l3mdev =dev_get_by_index_rcu (net, l3mdev_index); +if (!f6i || !f6i->fib6_prefsrc.plen || l3mdev) + dev = f6i ?fib6_info_nh_dev (f6i) :NULL ; + same_vrf = !l3mdev ||l3mdev_master_dev_rcu (dev) == l3mdev; +if (f6i && f6i->fib6_prefsrc.plen && same_vrf) *saddr = f6i->fib6_prefsrc.addr; - }else { -struct net_device *dev = f6i ?fib6_info_nh_dev (f6i) :NULL ; +else + err =ipv6_dev_get_saddr (net, same_vrf ? dev : l3mdev, daddr, prefs, saddr); - err =ipv6_dev_get_saddr (net, dev, daddr, prefs, saddr); - } +rcu_read_unlock ();return err; }
net/ipv6/ip6_output.c +1 -0
@@ -1124,6 +1124,7 @@ static int ip6_dst_lookup_tail(struct ne from = rt ?rcu_dereference (rt->from) :NULL ; err =ip6_route_get_saddr (net, from, &fl6->daddr, sk ?READ_ONCE (inet6_sk (sk)->srcprefs) :0 , + fl6->flowi6_l3mdev, &fl6->saddr);rcu_read_unlock ();
net/ipv6/route.c +1 -1
@@ -5689,7 +5689,7 @@ static int rt6_fill_node(struct net *net goto nla_put_failure; }else if (dest) {struct in6_addr saddr_buf; -if (ip6_route_get_saddr (net, rt, dest,0 , &saddr_buf) ==0 && +if (ip6_route_get_saddr (net, rt, dest,0 ,0 , &saddr_buf) ==0 &&nla_put_in6_addr (skb,RTA_PREFSRC , &saddr_buf)) goto nla_put_failure; }
Greg Kroah-Hartman
maintainerPATCH 555/809 ipv4: fix source address selection with route leak
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <[email protected]>
commit 6807352353561187a718e87204458999dbcbba1b upstream.
By default, an address assigned to the output interface is selected when the source address is not specified. This is problematic when a route, configured in a vrf, uses an interface from another vrf (aka route leak). The original vrf does not own the selected source address.
Let's add a check against the output interface and call the appropriate function to select the source address.
--- net/ipv4/fib_semantics.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/ipv4/fib_semantics.c +11 -2
@@ -2270,6 +2270,15 @@ void fib_select_path(struct net *net, stfib_select_default (fl4, res); check_saddr: -if (!fl4->saddr) - fl4->saddr =fib_result_prefsrc (net, res); +if (!fl4->saddr) { +struct net_device *l3mdev; + + l3mdev =dev_get_by_index_rcu (net, fl4->flowi4_l3mdev); + +if (!l3mdev || +l3mdev_master_dev_rcu (FIB_RES_DEV (*res)) == l3mdev) + fl4->saddr =fib_result_prefsrc (net, res); +else + fl4->saddr =inet_select_addr (l3mdev,0 ,RT_SCOPE_LINK ); + } }
Greg Kroah-Hartman
maintainerPATCH 556/809 ipv6: take care of scope when choosing the src addr
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <[email protected]>
commit abb9a68d2c64dd9b128ae1f2e635e4d805e7ce64 upstream.
When the source address is selected, the scope must be checked. For example, if a loopback address is assigned to the vrf device, it must not be chosen for packets sent outside.
--- net/ipv6/addrconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/addrconf.c +2 -1
@@ -1873,7 +1873,8 @@ int ipv6_dev_get_saddr(struct net *net, master, &dst, scores, hiscore_idx); -if (scores[hiscore_idx].ifa) +if (scores[hiscore_idx].ifa && + scores[hiscore_idx].scopedist >=0 ) goto out; }
Greg Kroah-Hartman
maintainerPATCH 557/809 drm/xe: Use write-back caching mode for system memory on DGFX
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <[email protected]>
commit 5207c393d3e7dda9aff813d6b3e2264370d241be upstream.
The caching mode for buffer objects with VRAM as a possible placement was forced to write-combined, regardless of placement.
However, write-combined system memory is expensive to allocate and even though it is pooled, the pool is expensive to shrink, since it involves global CPU TLB flushes.
Moreover write-combined system memory from TTM is only reliably available on x86 and DGFX doesn't have an x86 restriction.
So regardless of the cpu caching mode selected for a bo, internally use write-back caching mode for system memory on DGFX.
Coherency is maintained, but user-space clients may perceive a difference in cpu access speeds.
v2:
- Update RB- and Ack tags.
- Rephrase wording in xe_drm.h (Matt Roper)
v3:
- Really rephrase wording.
--- drivers/gpu/drm/xe/xe_bo.c | 47 +++++++++++++++++++++++---------------- drivers/gpu/drm/xe/xe_bo_types.h | 3 +- include/uapi/drm/xe_drm.h | 8 +++++- 3 files changed, 37 insertions(+), 21 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +28 -19
@@ -317,7 +317,7 @@ static struct ttm_tt *xe_ttm_tt_create(sstruct xe_device *xe =xe_bo_device (bo);struct xe_ttm_tt *tt;unsigned long extra_pages; -enum ttm_caching caching; +enum ttm_caching caching = ttm_cached;int err; tt =kzalloc (sizeof (*tt),GFP_KERNEL );
@@ -331,26 +331,35 @@ static struct ttm_tt *xe_ttm_tt_create(s extra_pages =DIV_ROUND_UP (xe_device_ccs_bytes (xe, bo->size),PAGE_SIZE ); -switch (bo->cpu_caching) { -case DRM_XE_GEM_CPU_CACHING_WC : - caching = ttm_write_combined; -break ; -default : - caching = ttm_cached; -break ; - } - -WARN_ON ((bo->flags &XE_BO_FLAG_USER ) && !bo->cpu_caching); -/* -* Display scanout is always non-coherent with the CPU cache. -* -* For Xe_LPG and beyond, PPGTT PTE lookups are also non-coherent and -* require a CPU:WC mapping. +* DGFX system memory is always WB / ttm_cached, since +* other caching modes are only supported on x86. DGFX +* GPU system memory accesses are always coherent with the +* CPU. */ -if ((!bo->cpu_caching && bo->flags &XE_BO_FLAG_SCANOUT ) || - (xe->info.graphics_verx100 >=1270 && bo->flags &XE_BO_FLAG_PAGETABLE )) - caching = ttm_write_combined; +if (!IS_DGFX (xe)) { +switch (bo->cpu_caching) { +case DRM_XE_GEM_CPU_CACHING_WC : + caching = ttm_write_combined; +break ; +default : + caching = ttm_cached; +break ; + } + +WARN_ON ((bo->flags &XE_BO_FLAG_USER ) && !bo->cpu_caching); + +/* +* Display scanout is always non-coherent with the CPU cache. +* +* For Xe_LPG and beyond, PPGTT PTE lookups are also +* non-coherent and require a CPU:WC mapping. +*/ +if ((!bo->cpu_caching && bo->flags &XE_BO_FLAG_SCANOUT ) || + (xe->info.graphics_verx100 >=1270 && + bo->flags &XE_BO_FLAG_PAGETABLE )) + caching = ttm_write_combined; + } err =ttm_tt_init (&tt->ttm, &bo->ttm, page_flags, caching, extra_pages);if (err) {
drivers/gpu/drm/xe/xe_bo_types.h +2 -1
@@ -66,7 +66,8 @@ struct xe_bo {/** * @cpu_caching: CPU caching mode. Currently only used for userspace -* objects. +* objects. Exceptions are system memory on DGFX, which is always +* WB. */ u16 cpu_caching;
include/uapi/drm/xe_drm.h +7 -1
@@ -776,7 +776,13 @@ struct drm_xe_gem_create {#define DRM_XE_GEM_CPU_CACHING_WC 2/** * @cpu_caching: The CPU caching mode to select for this object. If -* mmaping the object the mode selected here will also be used. +* mmaping the object the mode selected here will also be used. The +* exception is when mapping system memory (including data evicted +* to system) on discrete GPUs. The caching mode selected will +* then be overridden to DRM_XE_GEM_CPU_CACHING_WB, and coherency +* between GPU- and CPU is guaranteed. The caching mode of +* existing CPU-mappings will be updated transparently to +* user-space clients. */ __u16 cpu_caching;/** @pad: MBZ */
Greg Kroah-Hartman
maintainerPATCH 558/809 NFSD: Support write delegations in LAYOUTGET
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
commit abc02e5602f7bf9bbae1e8999570a2ad5114578c upstream.
I noticed LAYOUTGET(LAYOUTIOMODE4_RW) returning NFS4ERR_ACCESS unexpectedly. The NFS client had created a file with mode 0444, and the server had returned a write delegation on the OPEN(CREATE). The client was requesting a RW layout using the write delegation stateid so that it could flush file modifications.
Creating a read-only file does not seem to be problematic for NFSv4.1 without pNFS, so I began looking at NFSD's implementation of LAYOUTGET.
The failure was because fh_verify() was doing a permission check as part of verifying the FH presented during the LAYOUTGET. It uses the loga_iomode value to specify the @accmode argument to fh_verify(). fh_verify(MAY_WRITE) on a file whose mode is 0444 fails with -EACCES.
To permit LAYOUT* operations in this case, add OWNER_OVERRIDE when checking the access permission of the incoming file handle for LAYOUTGET and LAYOUTCOMMIT.
Cc: Christoph Hellwig <[email protected]>
Cc: [email protected] # v6.6+
Message-Id: [email protected]
--- fs/nfsd/nfs4proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -2
@@ -2269,7 +2269,7 @@ nfsd4_layoutget(struct svc_rqst *rqstp,const struct nfsd4_layout_ops *ops;struct nfs4_layout_stateid *ls;__be32 nfserr; -int accmode =NFSD_MAY_READ_IF_EXEC ; +int accmode =NFSD_MAY_READ_IF_EXEC |NFSD_MAY_OWNER_OVERRIDE ;switch (lgp->lg_seg.iomode) {case IOMODE_READ :
@@ -2359,7 +2359,8 @@ nfsd4_layoutcommit(struct svc_rqst *rqststruct nfs4_layout_stateid *ls;__be32 nfserr; - nfserr =fh_verify (rqstp, current_fh,0 ,NFSD_MAY_WRITE ); + nfserr =fh_verify (rqstp, current_fh,0 , +NFSD_MAY_WRITE |NFSD_MAY_OWNER_OVERRIDE );if (nfserr) goto out;
Greg Kroah-Hartman
maintainerPATCH 559/809 wifi: mac80211: chanctx emulation set CHANGE_CHANNEL when in_reconfig
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zong-Zhe Yang <[email protected]>
commit 19b815ed71aadee9a2d31b7a700ef61ae8048010 upstream.
Chanctx emulation didn't info IEEE80211_CONF_CHANGE_CHANNEL to drivers during ieee80211_restart_hw (ieee80211_emulate_add_chanctx). It caused non-chanctx drivers to not stand on the correct channel after recovery. RX then behaved abnormally. Finally, disconnection/reconnection occurred.
So, set IEEE80211_CONF_CHANGE_CHANNEL when in_reconfig.
--- net/mac80211/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/main.c +1 -1
@@ -148,7 +148,7 @@ static u32 ieee80211_calc_hw_conf_chan(struct ieee80211_local *local, offchannel_flag ^= local->hw.conf.flags &IEEE80211_CONF_OFFCHANNEL ;/* force it also for scanning, since drivers might config differently */ -if (offchannel_flag || local->scanning || +if (offchannel_flag || local->scanning || local->in_reconfig || !cfg80211_chandef_identical (&local->hw.conf.chandef, &chandef)) { local->hw.conf.chandef = chandef; changed |=IEEE80211_CONF_CHANGE_CHANNEL ;
Signature · 1 line
2.45.2
Greg Kroah-Hartman
maintainerPATCH 560/809 sched/fair: set_load_weight() must also call reweight_task() for SCHED_IDLE tasks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit d329605287020c3d1c3b0dadc63d8208e7251382 upstream.
When a task's weight is being changed, set_load_weight() is called with @update_load set. As weight changes aren't trivial for the fair class, set_load_weight() calls fair.c::reweight_task() for fair class tasks.
However, set_load_weight() first tests task_has_idle_policy() on entry and skips calling reweight_task() for SCHED_IDLE tasks. This is buggy as SCHED_IDLE tasks are just fair tasks with a very low weight and they would incorrectly skip load, vlag and position updates.
Fix it by updating reweight_task() to take struct load_weight as idle weight can't be expressed with prio and making set_load_weight() call reweight_task() for SCHED_IDLE tasks too when @update_load is set.
--- kernel/sched/core.c | 23 ++++++++++------------- kernel/sched/fair.c | 7 +++---- kernel/sched/sched.h | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-)
kernel/sched/core.c +10 -13
@@ -1326,27 +1326,24 @@ int tg_nop(struct task_group *tg, void *static void set_load_weight (struct task_struct *p,bool update_load) {int prio = p->static_prio -MAX_RT_PRIO ; -struct load_weight *load = &p->se.load; +struct load_weight lw; -/* -* SCHED_IDLE tasks get minimal weight: -*/ if (task_has_idle_policy (p)) { - load->weight =scale_load (WEIGHT_IDLEPRIO ); - load->inv_weight =WMULT_IDLEPRIO ; -return ; + lw.weight =scale_load (WEIGHT_IDLEPRIO ); + lw.inv_weight =WMULT_IDLEPRIO ; + }else { + lw.weight =scale_load (sched_prio_to_weight[prio]); + lw.inv_weight = sched_prio_to_wmult[prio]; }/* * SCHED_OTHER tasks have to update their load when changing their * weight */ -if (update_load && p->sched_class == &fair_sched_class) { -reweight_task (p, prio); - }else { - load->weight =scale_load (sched_prio_to_weight[prio]); - load->inv_weight = sched_prio_to_wmult[prio]; - } +if (update_load && p->sched_class == &fair_sched_class) +reweight_task (p, &lw); +else + p->se.load = lw; }#ifdef CONFIG_UCLAMP_TASK
kernel/sched/fair.c +3 -4
@@ -3835,15 +3835,14 @@ static void reweight_entity(struct cfs_r } } -void reweight_task (struct task_struct *p,int prio) +void reweight_task (struct task_struct *p,const struct load_weight *lw) {struct sched_entity *se = &p->se;struct cfs_rq *cfs_rq =cfs_rq_of (se);struct load_weight *load = &se->load; -unsigned long weight =scale_load (sched_prio_to_weight[prio]); -reweight_entity (cfs_rq, se, weight); - load->inv_weight = sched_prio_to_wmult[prio]; +reweight_entity (cfs_rq, se, lw->weight); + load->inv_weight = lw->inv_weight; }static inline int throttled_hierarchy (struct cfs_rq *cfs_rq);
kernel/sched/sched.h +1 -1
@@ -2464,7 +2464,7 @@ extern void init_sched_dl_class(void);extern void init_sched_rt_class (void );extern void init_sched_fair_class (void ); -extern void reweight_task (struct task_struct *p,int prio); +extern void reweight_task (struct task_struct *p,const struct load_weight *lw);extern void resched_curr (struct rq *rq);extern void resched_cpu (int cpu);
Greg Kroah-Hartman
maintainerPATCH 561/809 fuse: verify {g,u}id mount options correctly
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Sandeen <[email protected]>
commit 525bd65aa759ec320af1dc06e114ed69733e9e23 upstream.
As was done in0200679fc795 ("tmpfs: verify {g,u}id mount options correctly") we need to validate that the requested uid and/or gid is representable in the filesystem's idmapping.
Cribbing from the above commit log,
The contract for {g,u}id mount options and {g,u}id values in general set from userspace has always been that they are translated according to the caller's idmapping. In so far, fuse has been doing the correct thing. But since fuse is mountable in unprivileged contexts it is also necessary to verify that the resulting {k,g}uid is representable in the namespace of the superblock.
--- fs/fuse/inode.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
fs/fuse/inode.c +20 -4
@@ -755,6 +755,8 @@ static int fuse_parse_param(struct fs_costruct fs_parse_result result;struct fuse_fs_context *ctx = fsc->fs_private;int opt; +kuid_t kuid; +kgid_t kgid;if (fsc->purpose ==FS_CONTEXT_FOR_RECONFIGURE ) {/*
@@ -799,16 +801,30 @@ static int fuse_parse_param(struct fs_cobreak ;case OPT_USER_ID : - ctx->user_id =make_kuid (fsc->user_ns, result.uint_32); -if (!uid_valid (ctx->user_id)) + kuid =make_kuid (fsc->user_ns, result.uint_32); +if (!uid_valid (kuid))return invalfc (fsc,"Invalid user_id" ); +/* +* The requested uid must be representable in the +* filesystem's idmapping. +*/ +if (!kuid_has_mapping (fsc->user_ns, kuid)) +return invalfc (fsc,"Invalid user_id" ); + ctx->user_id = kuid; ctx->user_id_present = true;break ;case OPT_GROUP_ID : - ctx->group_id =make_kgid (fsc->user_ns, result.uint_32); -if (!gid_valid (ctx->group_id)) + kgid =make_kgid (fsc->user_ns, result.uint_32);; +if (!gid_valid (kgid)) +return invalfc (fsc,"Invalid group_id" ); +/* +* The requested gid must be representable in the +* filesystem's idmapping. +*/ +if (!kgid_has_mapping (fsc->user_ns, kgid))return invalfc (fsc,"Invalid group_id" ); + ctx->group_id = kgid; ctx->group_id_present = true;break ;
Greg Kroah-Hartman
maintainerPATCH 562/809 md/raid5: fix spares errors about rcu usage
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit 2314c2e3a70521f055dd011245dccf6fd97c7ee0 upstream.
As commit ad8606702f26 ("md/raid5: remove rcu protection to access rdev from conf") explains, rcu protection can be removed, however, there are three places left, there won't be any real problems.
drivers/md/raid5.c:8071:24: error: incompatible types in comparison expression (different address spaces):drivers/md/raid5.c:8071:24: struct md_rdev [noderef] __rcu *drivers/md/raid5.c:8071:24: struct md_rdev *drivers/md/raid5.c:7569:25: error: incompatible types in comparison expression (different address spaces):drivers/md/raid5.c:7569:25: struct md_rdev [noderef] __rcu *drivers/md/raid5.c:7569:25: struct md_rdev *drivers/md/raid5.c:7573:25: error: incompatible types in comparison expression (different address spaces):drivers/md/raid5.c:7573:25: struct md_rdev [noderef] __rcu *drivers/md/raid5.c:7573:25: struct md_rdev *
--- drivers/md/raid5.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/md/raid5.c +5 -7
@@ -155,7 +155,7 @@ static int raid6_idx_to_slot(int idx, streturn slot; } -static void print_raid5_conf (struct r5conf *conf); +static void print_raid5_conf (struct r5conf *conf);static int stripe_operations_active (struct stripe_head *sh) {
@@ -7580,11 +7580,11 @@ static struct r5conf *setup_conf(structif (test_bit (Replacement, &rdev->flags)) {if (disk->replacement) goto abort; -RCU_INIT_POINTER (disk->replacement, rdev); + disk->replacement = rdev; }else {if (disk->rdev) goto abort; -RCU_INIT_POINTER (disk->rdev, rdev); + disk->rdev = rdev; }if (test_bit (In_sync, &rdev->flags)) {
@@ -8066,7 +8066,7 @@ static void raid5_status(struct seq_fileseq_printf (seq,"]" ); } -static void print_raid5_conf (struct r5conf *conf) +static void print_raid5_conf (struct r5conf *conf) {struct md_rdev *rdev;int i;
@@ -8080,15 +8080,13 @@ static void print_raid5_conf (struct r5c conf->raid_disks, conf->raid_disks - conf->mddev->degraded); -rcu_read_lock ();for (i =0 ; i < conf->raid_disks; i++) { - rdev =rcu_dereference (conf->disks[i].rdev); + rdev = conf->disks[i].rdev;if (rdev)pr_debug (" disk %d, o:%d, dev:%pg\n" , i, !test_bit (Faulty, &rdev->flags), rdev->bdev); } -rcu_read_unlock (); }static int raid5_spare_active (struct mddev *mddev)
Greg Kroah-Hartman
maintainerPATCH 563/809 media: stm32: dcmipp: correct error handling in dcmipp_create_subdevs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
commit a7351f0d3668b449fdc2cfd90403b1cb1f03ed6d upstream.
Correct error handling within the dcmipp_create_subdevs by properly decrementing the i counter when releasing the subdevs.
--- drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c +2 -2
@@ -202,8 +202,8 @@ static int dcmipp_create_subdevs(structreturn 0 ; err_init_entity: -while (i >0 ) - dcmipp->pipe_cfg->ents[i -1 ].release (dcmipp->entity[i -1 ]); +while (i-- >0 ) + dcmipp->pipe_cfg->ents[i].release (dcmipp->entity[i]);return ret; }
Greg Kroah-Hartman
maintainerPATCH 564/809 null_blk: Fix description of the fua parameter
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 1c0b3fca381bf879e2168b362692f83808677f95 upstream.
The description of the fua module parameter is defined using MODULE_PARM_DESC() with the first argument passed being "zoned". That is the wrong name, obviously. Fix that by using the correct "fua" parameter name so that "modinfo null_blk" displays correct information.
--- drivers/block/null_blk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/null_blk/main.c +1 -1
@@ -227,7 +227,7 @@ MODULE_PARM_DESC(mbps, "Cache size in MiB for memory-backed device. Default: 0 (static bool g_fua = true;module_param_named (fua, g_fua, bool,0444 ); -MODULE_PARM_DESC (zoned,"Enable/disable FUA support when cache_size is used. Default: true" ); +MODULE_PARM_DESC (fua,"Enable/disable FUA support when cache_size is used. Default: true" );static unsigned int g_mbps;module_param_named (mbps, g_mbps, uint,0444 );
Signature · 1 line
2.45.2
Greg Kroah-Hartman
maintainerPATCH 565/809 ata: libata-scsi: Fix offsets for the fixed format sense data
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Pylypiv <[email protected]>
commit 38dab832c3f4154968f95b267a3bb789e87554b0 upstream.
Correct the ATA PASS-THROUGH fixed format sense data offsets to conform to SPC-6 and SAT-5 specifications. Additionally, set the VALID bit to indicate that the INFORMATION field contains valid information.
INFORMATION
===========
SAT-5 Table 212 — "Fixed format sense data INFORMATION field for the ATA PASS-THROUGH commands" defines the following format:
+------+------------+ | Byte | Field | +------+------------+ | 0 | ERROR | | 1 | STATUS | | 2 | DEVICE | | 3 | COUNT(7:0) | +------+------------+
SPC-6 Table 48 - "Fixed format sense data" specifies that the INFORMATION field starts at byte 3 in sense buffer resulting in the following offsets for the ATA PASS-THROUGH commands:
+------------+-------------------------+ | Field | Offset in sense buffer | +------------+-------------------------+ | ERROR | 3 | | STATUS | 4 | | DEVICE | 5 | | COUNT(7:0) | 6 | +------------+-------------------------+
COMMAND-SPECIFIC INFORMATION
============================
SAT-5 Table 213 - "Fixed format sense data COMMAND-SPECIFIC INFORMATION field for ATA PASS-THROUGH" defines the following format:
+------+-------------------+ | Byte | Field | +------+-------------------+ | 0 | FLAGS | LOG INDEX | | 1 | LBA (7:0) | | 2 | LBA (15:8) | | 3 | LBA (23:16) | +------+-------------------+
SPC-6 Table 48 - "Fixed format sense data" specifies that the COMMAND-SPECIFIC-INFORMATION field starts at byte 8 in sense buffer resulting in the following offsets for the ATA PASS-THROUGH commands:
Offsets of these fields in the fixed sense format are as follows:
+-------------------+-------------------------+ | Field | Offset in sense buffer | +-------------------+-------------------------+ | FLAGS | LOG INDEX | 8 | | LBA (7:0) | 9 | | LBA (15:8) | 10 | | LBA (23:16) | 11 | +-------------------+-------------------------+
--- drivers/ata/libata-scsi.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/ata/libata-scsi.c +13 -13
@@ -855,7 +855,6 @@ static void ata_gen_passthru_sense(strucstruct scsi_cmnd *cmd = qc->scsicmd;struct ata_taskfile *tf = &qc->result_tf;unsigned char *sb = cmd->sense_buffer; -unsigned char *desc = sb +8 ;u8 sense_key, asc, ascq;memset (sb,0 ,SCSI_SENSE_BUFFERSIZE );
@@ -877,7 +876,8 @@ static void ata_gen_passthru_sense(strucscsi_build_sense (cmd,1 ,RECOVERED_ERROR ,0 ,0x1D ); } -if ((cmd->sense_buffer[0 ] &0x7f ) >=0x72 ) { +if ((sb[0 ] &0x7f ) >=0x72 ) { +unsigned char *desc;u8 len;/* descriptor format */
@@ -916,21 +916,21 @@ static void ata_gen_passthru_sense(struc } }else {/* Fixed sense format */ - desc[0 ] = tf->error; - desc[1 ] = tf->status; - desc[2 ] = tf->device; - desc[3 ] = tf->nsect; - desc[7 ] =0 ; + sb[0 ] |=0x80 ; + sb[3 ] = tf->error; + sb[4 ] = tf->status; + sb[5 ] = tf->device; + sb[6 ] = tf->nsect;if (tf->flags &ATA_TFLAG_LBA48 ) { - desc[8 ] |=0x80 ; + sb[8 ] |=0x80 ;if (tf->hob_nsect) - desc[8 ] |=0x40 ; + sb[8 ] |=0x40 ;if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah) - desc[8 ] |=0x20 ; + sb[8 ] |=0x20 ; } - desc[9 ] = tf->lbal; - desc[10 ] = tf->lbam; - desc[11 ] = tf->lbah; + sb[9 ] = tf->lbal; + sb[10 ] = tf->lbam; + sb[11 ] = tf->lbah; } }
Greg Kroah-Hartman
maintainerPATCH 566/809 selftests/nolibc: fix printf format mismatch in expect_str_buf_eq()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 92098b1c10cb29bcc6fa0908a766dc9e16b1e889 upstream.
Fix the following compiler warning on 32bit:
i386-linux-gcc -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra -fno-stack-protector -m32 -mstack-protector-guard=global -fstack-protector-all -o nolibc-test \
-nostdlib -nostdinc -static -Isysroot/i386/include nolibc-test.c nolibc-test-linkage.c -lgcc
nolibc-test.c: In function 'expect_str_buf_eq':
nolibc-test.c:610:30: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
610 | llen += printf(" = %lu <%s> ", expr, buf);
| ~~^ ~~~~
| | |
| | size_t {aka unsigned int}
| long unsigned int
| %u--- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/nolibc/nolibc-test.c +1 -1
@@ -607,7 +607,7 @@ int expect_strne(const char *expr, int llen, const char *cmp)static __attribute__((unused))int expect_str_buf_eq (size_t expr,const char *buf,size_t val,int llen,const char *cmp) { - llen +=printf (" = %lu <%s> " , expr, buf); + llen +=printf (" = %lu <%s> " , (unsigned long )expr, buf);if (strcmp (buf, cmp) !=0 ) {result (llen,FAIL );return 1 ;
Signature · 1 line
2.45.2
Greg Kroah-Hartman
maintainerPATCH 567/809 tpm_tis_spi: add missing attpm20p SPI device ID entry
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitor Soares <[email protected]>
commit 0543f29408a151c1c4a12e5da07ec45c2779b9b8 upstream.
"atmel,attpm20p" DT compatible is missing its SPI device ID entry, not allowing module autoloading and leading to the following message:
"SPI driver tpm_tis_spi has no spi_device_id for atmel,attpm20p"
Based on:
commit 7eba41fe8c7b ("tpm_tis_spi: Add missing SPI ID")
Fix this by adding the corresponding "attpm20p" spi_device_id entry.
--- drivers/char/tpm/tpm_tis_spi_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/tpm/tpm_tis_spi_main.c +1 -0
@@ -318,6 +318,7 @@ static void tpm_tis_spi_remove(struct spi_device *dev) }static const struct spi_device_id tpm_tis_spi_id[] = { + {"attpm20p" , (unsigned long )tpm_tis_spi_probe }, {"st33htpm-spi" , (unsigned long )tpm_tis_spi_probe }, {"slb9670" , (unsigned long )tpm_tis_spi_probe }, {"tpm_tis_spi" , (unsigned long )tpm_tis_spi_probe },
Signature · 1 line
2.45.2
Greg Kroah-Hartman
maintainerPATCH 568/809 char: tpm: Fix possible memory leak in tpm_bios_measurements_open()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
commit 5d8e2971e817bb64225fc0b6327a78752f58a9aa upstream.
In tpm_bios_measurements_open(), get_device() is called on the device embedded in struct tpm_chip. In the error path, however, put_device() is not called. This results in a reference count leak, which prevents the device from being properly released. This commit makes sure to call put_device() when the seq_open() call fails.
--- drivers/char/tpm/eventlog/common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/char/tpm/eventlog/common.c +2 -0
@@ -47,6 +47,8 @@ static int tpm_bios_measurements_open(stif (!err) { seq = file->private_data; seq->private = chip; + }else { +put_device (&chip->dev); }return err;
Greg Kroah-Hartman
maintainerPATCH 569/809 media: venus: fix use after free in vdec_close
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dikshita Agarwal <[email protected]>
commit a0157b5aa34eb43ec4c5510f9c260bbb03be937e upstream.
There appears to be a possible use after free with vdec_close(). The firmware will add buffer release work to the work queue through HFI callbacks as a normal part of decoding. Randomly closing the decoder device from userspace during normal decoding can incur a read after free for inst.
Fix it by cancelling the work in vdec_close.
--- drivers/media/platform/qcom/venus/vdec.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/venus/vdec.c +1 -0
@@ -1747,6 +1747,7 @@ static int vdec_close(struct file *file)vdec_pm_get (inst); +cancel_work_sync (&inst->delayed_process_work);v4l2_m2m_ctx_release (inst->m2m_ctx);v4l2_m2m_release (inst->m2m_dev);vdec_ctrl_deinit (inst);
Greg Kroah-Hartman
maintainerPATCH 570/809 ata: libata-scsi: Do not overwrite valid sense data when CK_COND=1
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Pylypiv <[email protected]>
commit 97981926224afe17ba3e22e0c2b7dd8b516ee574 upstream.
Current ata_gen_passthru_sense() code performs two actions:
1. Generates sense data based on the ATA 'status' and ATA 'error' fields.
2. Populates "ATA Status Return sense data descriptor" / "Fixed format sense data" with ATA taskfile fields.
The problem is that #1 generates sense data even when a valid sense data is already present (ATA_QCFLAG_SENSE_VALID is set). Factoring out #2 into a separate function allows us to generate sense data only when there is no valid sense data (ATA_QCFLAG_SENSE_VALID is not set).
As a bonus, we can now delete a FIXME comment in atapi_qc_complete() which states that we don't want to translate taskfile registers into sense descriptors for ATAPI.
Additionally, always set SAM_STAT_CHECK_CONDITION when CK_COND=1 because SAT specification mandates that SATL shall return CHECK CONDITION if the CK_COND bit is set.
The ATA PASS-THROUGH handling logic in ata_scsi_qc_complete() is hard to read/understand. Improve the readability of the code by moving checks into self-explanatory boolean variables.
--- drivers/ata/libata-scsi.c | 169 +++++++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 77 deletions(-)
drivers/ata/libata-scsi.c +92 -77
@@ -230,6 +230,80 @@ void ata_scsi_set_sense_information(stru SCSI_SENSE_BUFFERSIZE, information); } +/** +* ata_scsi_set_passthru_sense_fields - Set ATA fields in sense buffer +* @qc: ATA PASS-THROUGH command. +* +* Populates "ATA Status Return sense data descriptor" / "Fixed format +* sense data" with ATA taskfile fields. +* +* LOCKING: +* None. +*/ +static void ata_scsi_set_passthru_sense_fields (struct ata_queued_cmd *qc) +{ +struct scsi_cmnd *cmd = qc->scsicmd; +struct ata_taskfile *tf = &qc->result_tf; +unsigned char *sb = cmd->sense_buffer; + +if ((sb[0 ] &0x7f ) >=0x72 ) { +unsigned char *desc; +u8 len; + +/* descriptor format */ + len = sb[7 ]; + desc = (char *)scsi_sense_desc_find (sb, len +8 ,9 ); +if (!desc) { +if (SCSI_SENSE_BUFFERSIZE < len +14 ) +return ; + sb[7 ] = len +14 ; + desc = sb +8 + len; + } + desc[0 ] =9 ; + desc[1 ] =12 ; +/* +* Copy registers into sense buffer. +*/ + desc[2 ] =0x00 ; + desc[3 ] = tf->error; + desc[5 ] = tf->nsect; + desc[7 ] = tf->lbal; + desc[9 ] = tf->lbam; + desc[11 ] = tf->lbah; + desc[12 ] = tf->device; + desc[13 ] = tf->status; + +/* +* Fill in Extend bit, and the high order bytes +* if applicable. +*/ +if (tf->flags &ATA_TFLAG_LBA48 ) { + desc[2 ] |=0x01 ; + desc[4 ] = tf->hob_nsect; + desc[6 ] = tf->hob_lbal; + desc[8 ] = tf->hob_lbam; + desc[10 ] = tf->hob_lbah; + } + }else { +/* Fixed sense format */ + sb[0 ] |=0x80 ; + sb[3 ] = tf->error; + sb[4 ] = tf->status; + sb[5 ] = tf->device; + sb[6 ] = tf->nsect; +if (tf->flags &ATA_TFLAG_LBA48 ) { + sb[8 ] |=0x80 ; +if (tf->hob_nsect) + sb[8 ] |=0x40 ; +if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah) + sb[8 ] |=0x20 ; + } + sb[9 ] = tf->lbal; + sb[10 ] = tf->lbam; + sb[11 ] = tf->lbah; + } +} +static void ata_scsi_set_invalid_field (struct ata_device *dev,struct scsi_cmnd *cmd,u16 field,u8 bit) {
@@ -837,10 +911,8 @@ static void ata_to_sense_error(unsigned* ata_gen_passthru_sense - Generate check condition sense block. * @qc: Command that completed. * -* This function is specific to the ATA descriptor format sense -* block specified for the ATA pass through commands. Regardless -* of whether the command errored or not, return a sense -* block. Copy all controller registers into the sense +* This function is specific to the ATA pass through commands. +* Regardless of whether the command errored or not, return a sense * block. If there was no error, we get the request from an ATA * passthrough command, so we use the following sense data: * sk = RECOVERED ERROR
@@ -875,63 +947,6 @@ static void ata_gen_passthru_sense(struc*/ scsi_build_sense (cmd,1 ,RECOVERED_ERROR ,0 ,0x1D ); } - -if ((sb[0 ] &0x7f ) >=0x72 ) { -unsigned char *desc; -u8 len; - -/* descriptor format */ - len = sb[7 ]; - desc = (char *)scsi_sense_desc_find (sb, len +8 ,9 ); -if (!desc) { -if (SCSI_SENSE_BUFFERSIZE < len +14 ) -return ; - sb[7 ] = len +14 ; - desc = sb +8 + len; - } - desc[0 ] =9 ; - desc[1 ] =12 ; -/* -* Copy registers into sense buffer. -*/ - desc[2 ] =0x00 ; - desc[3 ] = tf->error; - desc[5 ] = tf->nsect; - desc[7 ] = tf->lbal; - desc[9 ] = tf->lbam; - desc[11 ] = tf->lbah; - desc[12 ] = tf->device; - desc[13 ] = tf->status; - -/* -* Fill in Extend bit, and the high order bytes -* if applicable. -*/ -if (tf->flags &ATA_TFLAG_LBA48 ) { - desc[2 ] |=0x01 ; - desc[4 ] = tf->hob_nsect; - desc[6 ] = tf->hob_lbal; - desc[8 ] = tf->hob_lbam; - desc[10 ] = tf->hob_lbah; - } - }else { -/* Fixed sense format */ - sb[0 ] |=0x80 ; - sb[3 ] = tf->error; - sb[4 ] = tf->status; - sb[5 ] = tf->device; - sb[6 ] = tf->nsect; -if (tf->flags &ATA_TFLAG_LBA48 ) { - sb[8 ] |=0x80 ; -if (tf->hob_nsect) - sb[8 ] |=0x40 ; -if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah) - sb[8 ] |=0x20 ; - } - sb[9 ] = tf->lbal; - sb[10 ] = tf->lbam; - sb[11 ] = tf->lbah; - } }/**
@@ -1632,26 +1647,32 @@ static void ata_scsi_qc_complete(struct {struct scsi_cmnd *cmd = qc->scsicmd;u8 *cdb = cmd->cmnd; -int need_sense = (qc->err_mask !=0 ) && - !(qc->flags &ATA_QCFLAG_SENSE_VALID ); +bool have_sense = qc->flags &ATA_QCFLAG_SENSE_VALID ; +bool is_ata_passthru = cdb[0 ] ==ATA_16 || cdb[0 ] ==ATA_12 ; +bool is_ck_cond_request = cdb[2 ] &0x20 ; +bool is_error = qc->err_mask !=0 ;/* For ATA pass thru (SAT) commands, generate a sense block if * user mandated it or if there's an error. Note that if we -* generate because the user forced us to [CK_COND =1], a check +* generate because the user forced us to [CK_COND=1], a check * condition is generated and the ATA register values are returned * whether the command completed successfully or not. If there -* was no error, we use the following sense data: +* was no error, and CK_COND=1, we use the following sense data: * sk = RECOVERED ERROR * asc,ascq = ATA PASS-THROUGH INFORMATION AVAILABLE */ -if (((cdb[0 ] ==ATA_16 ) || (cdb[0 ] ==ATA_12 )) && - ((cdb[2 ] &0x20 ) || need_sense)) -ata_gen_passthru_sense (qc); -else if (need_sense) +if (is_ata_passthru && (is_ck_cond_request || is_error || have_sense)) { +if (!have_sense) +ata_gen_passthru_sense (qc); +ata_scsi_set_passthru_sense_fields (qc); +if (is_ck_cond_request) +set_status_byte (qc->scsicmd,SAM_STAT_CHECK_CONDITION ); + }else if (is_error && !have_sense) {ata_gen_ata_sense (qc); -else + }else {/* Keep the SCSI ML and status byte, clear host byte. */ cmd->result &=0x0000ffff ; + }ata_qc_done (qc); }
@@ -2590,14 +2611,8 @@ static void atapi_qc_complete(struct ata/* handle completion from EH */ if (unlikely (err_mask || qc->flags &ATA_QCFLAG_SENSE_VALID )) { -if (!(qc->flags &ATA_QCFLAG_SENSE_VALID )) { -/* FIXME: not quite right; we don't want the -* translation of taskfile registers into a -* sense descriptors, since that's only -* correct for ATA, not ATAPI -*/ +if (!(qc->flags &ATA_QCFLAG_SENSE_VALID ))ata_gen_passthru_sense (qc); - }/* SCSI EH automatically locks door if sdev->locked is * set. Sometimes door lock request continues to
Greg Kroah-Hartman
maintainerPATCH 571/809 ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Pylypiv <[email protected]>
commit 28ab9769117ca944cb6eb537af5599aa436287a4 upstream.
SAT-5 revision 8 specification removed the text about the ANSI INCITS 431-2007 compliance which was requiring SCSI/ATA Translation (SAT) to return descriptor format sense data for the ATA PASS-THROUGH commands regardless of the setting of the D_SENSE bit.
Let's honor the D_SENSE bit for ATA PASS-THROUGH commands while generating the "ATA PASS-THROUGH INFORMATION AVAILABLE" sense data.
SAT-5 revision 7
================
12.2.2.8 Fixed format sense data
Table 212 shows the fields returned in the fixed format sense data (see SPC-5) for ATA PASS-THROUGH commands. SATLs compliant with ANSI INCITS 431-2007, SCSI/ATA Translation (SAT) return descriptor format sense data for the ATA PASS-THROUGH commands regardless of the setting of the D_SENSE bit.
SAT-5 revision 8
================
12.2.2.8 Fixed format sense data
Table 211 shows the fields returned in the fixed format sense data (see SPC-5) for ATA PASS-THROUGH commands.
--- drivers/ata/libata-scsi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/ata/libata-scsi.c +2 -5
@@ -941,11 +941,8 @@ static void ata_gen_passthru_sense(struc &sense_key, &asc, &ascq);ata_scsi_set_sense (qc->dev, cmd, sense_key, asc, ascq); }else { -/* -* ATA PASS-THROUGH INFORMATION AVAILABLE -* Always in descriptor format sense. -*/ -scsi_build_sense (cmd,1 ,RECOVERED_ERROR ,0 ,0x1D ); +/* ATA PASS-THROUGH INFORMATION AVAILABLE */ +ata_scsi_set_sense (qc->dev, cmd,RECOVERED_ERROR ,0 ,0x1D ); } }
Greg Kroah-Hartman
maintainerPATCH 572/809 sysctl: always initialize i_uid/i_gid
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 98ca62ba9e2be5863c7d069f84f7166b45a5b2f4 upstream.
Always initialize i_uid/i_gid inside the sysfs core so set_ownership() can safely skip setting them.
Commit 5ec27ec735ba ("fs/proc/proc_sysctl.c: fix the default values of i_uid/i_gid on /proc/sys inodes.") added defaults for i_uid/i_gid when set_ownership() was not implemented. It also missed adjusting net_ctl_set_ownership() to use the same default values in case the computation of a better value failed.
--- fs/proc/proc_sysctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/proc/proc_sysctl.c +2 -4
@@ -476,12 +476,10 @@ static struct inode *proc_sys_make_inodemake_empty_dir_inode (inode); } + inode->i_uid =GLOBAL_ROOT_UID ; + inode->i_gid =GLOBAL_ROOT_GID ;if (root->set_ownership) root->set_ownership (head, &inode->i_uid, &inode->i_gid); -else { - inode->i_uid =GLOBAL_ROOT_UID ; - inode->i_gid =GLOBAL_ROOT_GID ; - }return inode; }
Greg Kroah-Hartman
maintainerPATCH 573/809 hfs: fix to initialize fields of hfs_inode_info after hfs_alloc_inode()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 26a2ed107929a855155429b11e1293b83e6b2a8b upstream.
Syzbot reports uninitialized value access issue as below:
loop0: detected capacity change from 0 to 64
=====================================================
BUG: KMSAN: uninit-value in hfs_revalidate_dentry+0x307/0x3f0 fs/hfs/sysdep.c:30 hfs_revalidate_dentry+0x307/0x3f0 fs/hfs/sysdep.c:30 d_revalidate fs/namei.c:862 [inline] lookup_fast+0x89e/0x8e0 fs/namei.c:1649 walk_component fs/namei.c:2001 [inline] link_path_walk+0x817/0x1480 fs/namei.c:2332 path_lookupat+0xd9/0x6f0 fs/namei.c:2485 filename_lookup+0x22e/0x740 fs/namei.c:2515 user_path_at_empty+0x8b/0x390 fs/namei.c:2924 user_path_at include/linux/namei.h:57 [inline] do_mount fs/namespace.c:3689 [inline] __do_sys_mount fs/namespace.c:3898 [inline] __se_sys_mount+0x66b/0x810 fs/namespace.c:3875 __x64_sys_mount+0xe4/0x140 fs/namespace.c:3875 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b BUG: KMSAN: uninit-value in hfs_ext_read_extent fs/hfs/extent.c:196 [inline] BUG: KMSAN: uninit-value in hfs_get_block+0x92d/0x1620 fs/hfs/extent.c:366 hfs_ext_read_extent fs/hfs/extent.c:196 [inline] hfs_get_block+0x92d/0x1620 fs/hfs/extent.c:366 block_read_full_folio+0x4ff/0x11b0 fs/buffer.c:2271 hfs_read_folio+0x55/0x60 fs/hfs/inode.c:39 filemap_read_folio+0x148/0x4f0 mm/filemap.c:2426 do_read_cache_folio+0x7c8/0xd90 mm/filemap.c:3553 do_read_cache_page mm/filemap.c:3595 [inline] read_cache_page+0xfb/0x2f0 mm/filemap.c:3604 read_mapping_page include/linux/pagemap.h:755 [inline] hfs_btree_open+0x928/0x1ae0 fs/hfs/btree.c:78 hfs_mdb_get+0x260c/0x3000 fs/hfs/mdb.c:204 hfs_fill_super+0x1fb1/0x2790 fs/hfs/super.c:406 mount_bdev+0x628/0x920 fs/super.c:1359 hfs_mount+0xcd/0xe0 fs/hfs/super.c:456 legacy_get_tree+0x167/0x2e0 fs/fs_context.c:610 vfs_get_tree+0xdc/0x5d0 fs/super.c:1489 do_new_mount+0x7a9/0x16f0 fs/namespace.c:3145 path_mount+0xf98/0x26a0 fs/namespace.c:3475 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x919/0x9e0 fs/namespace.c:3674 __ia32_sys_mount+0x15b/0x1b0 fs/namespace.c:3674 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0xa2/0x100 arch/x86/entry/common.c:178 do_fast_syscall_32+0x37/0x80 arch/x86/entry/common.c:203 do_SYSENTER_32+0x1f/0x30 arch/x86/entry/common.c:246 entry_SYSENTER_compat_after_hwframe+0x70/0x82
Uninit was created at:
__alloc_pages+0x9a6/0xe00 mm/page_alloc.c:4590 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page mm/slub.c:2190 [inline] allocate_slab mm/slub.c:2354 [inline] new_slab+0x2d7/0x1400 mm/slub.c:2407 ___slab_alloc+0x16b5/0x3970 mm/slub.c:3540 __slab_alloc mm/slub.c:3625 [inline] __slab_alloc_node mm/slub.c:3678 [inline] slab_alloc_node mm/slub.c:3850 [inline] kmem_cache_alloc_lru+0x64d/0xb30 mm/slub.c:3879 alloc_inode_sb include/linux/fs.h:3018 [inline] hfs_alloc_inode+0x5a/0xc0 fs/hfs/super.c:165 alloc_inode+0x83/0x440 fs/inode.c:260 new_inode_pseudo fs/inode.c:1005 [inline] new_inode+0x38/0x4f0 fs/inode.c:1031 hfs_new_inode+0x61/0x1010 fs/hfs/inode.c:186 hfs_mkdir+0x54/0x250 fs/hfs/dir.c:228 vfs_mkdir+0x49a/0x700 fs/namei.c:4126 do_mkdirat+0x529/0x810 fs/namei.c:4149 __do_sys_mkdirat fs/namei.c:4164 [inline] __se_sys_mkdirat fs/namei.c:4162 [inline] __x64_sys_mkdirat+0xc8/0x120 fs/namei.c:4162 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b
It missed to initialize .tz_secondswest, .cached_start and .cached_blocks fields in struct hfs_inode_info after hfs_alloc_inode(), fix it.
--- fs/hfs/inode.c | 3 +++ 1 file changed, 3 insertions(+)
fs/hfs/inode.c +3 -0
@@ -200,6 +200,7 @@ struct inode *hfs_new_inode(struct inodeHFS_I (inode)->flags =0 ;HFS_I (inode)->rsrc_inode =NULL ;HFS_I (inode)->fs_blocks =0 ; +HFS_I (inode)->tz_secondswest = sys_tz.tz_minuteswest *60 ;if (S_ISDIR (mode)) { inode->i_size =2 ;HFS_SB (sb)->folder_count++;
@@ -275,6 +276,8 @@ void hfs_inode_read_fork(struct inode *ifor (count =0 , i =0 ; i <3 ; i++) count +=be16_to_cpu (ext[i].count);HFS_I (inode)->first_blocks = count; +HFS_I (inode)->cached_start =0 ; +HFS_I (inode)->cached_blocks =0 ; inode->i_size =HFS_I (inode)->phys_size = log_size;HFS_I (inode)->fs_blocks = (log_size + sb->s_blocksize -1 ) >> sb->s_blocksize_bits;
Greg Kroah-Hartman
maintainerPATCH 574/809 ext2: Verify bitmap and itable block numbers before using them
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 322a6aff03937aa1ece33b4e46c298eafaf9ac41 upstream.
Verify bitmap block numbers and inode table blocks are sane before using them for checking bits in the block bitmap.
--- fs/ext2/balloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ext2/balloc.c +9 -2
@@ -77,26 +77,33 @@ static int ext2_valid_block_bitmap(strucext2_grpblk_t next_zero_bit;ext2_fsblk_t bitmap_blk;ext2_fsblk_t group_first_block; +ext2_grpblk_t max_bit; group_first_block =ext2_group_first_block_no (sb, block_group); + max_bit =ext2_group_last_block_no (sb, block_group) - group_first_block;/* check whether block bitmap block number is set */ bitmap_blk =le32_to_cpu (desc->bg_block_bitmap); offset = bitmap_blk - group_first_block; -if (!ext2_test_bit (offset, bh->b_data)) +if (offset <0 || offset > max_bit || + !ext2_test_bit (offset, bh->b_data))/* bad block bitmap */ goto err_out;/* check whether the inode bitmap block number is set */ bitmap_blk =le32_to_cpu (desc->bg_inode_bitmap); offset = bitmap_blk - group_first_block; -if (!ext2_test_bit (offset, bh->b_data)) +if (offset <0 || offset > max_bit || + !ext2_test_bit (offset, bh->b_data))/* bad block bitmap */ goto err_out;/* check whether the inode table block number is set */ bitmap_blk =le32_to_cpu (desc->bg_inode_table); offset = bitmap_blk - group_first_block; +if (offset <0 || offset > max_bit || + offset +EXT2_SB (sb)->s_itb_per_group -1 > max_bit) + goto err_out; next_zero_bit =ext2_find_next_zero_bit (bh->b_data, offset +EXT2_SB (sb)->s_itb_per_group, offset);
Greg Kroah-Hartman
maintainerPATCH 575/809 media: i2c: Kconfig: Fix missing firmware upload config select
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kory Maincent <[email protected]>
commit fea074e97886b7ee2fe04a17bd60fd41723da1b7 upstream.
FW_LOADER config only selects the firmware loader API, but we also need the sysfs_upload symbols for firmware_upload_unregister() and firmware_upload_register() to function properly.
--- drivers/media/i2c/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/Kconfig +1 -0
@@ -679,6 +679,7 @@ config VIDEO_THP7312 tristate "THine THP7312 support" depends on I2C select FW_LOADER + select FW_UPLOAD select MEDIA_CONTROLLER select V4L2_CCI_I2C select V4L2_FWNODE
Greg Kroah-Hartman
maintainerPATCH 576/809 lsm: fixup the inode xattr capability handling
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moore <[email protected]>
commit 61df7b82820494368bd46071ca97e43a3dfc3b11 upstream.
The current security_inode_setxattr() and security_inode_removexattr() hooks rely on individual LSMs to either call into the associated capability hooks (cap_inode_setxattr() or cap_inode_removexattr()), or return a magic value of 1 to indicate that the LSM layer itself should perform the capability checks. Unfortunately, with the default return value for these LSM hooks being 0, an individual LSM hook returning a 1 will cause the LSM hook processing to exit early, potentially skipping a LSM. Thankfully, with the exception of the BPF LSM, none of the LSMs which currently register inode xattr hooks should end up returning a value of 1, and in the BPF LSM case, with the BPF LSM hooks executing last there should be no real harm in stopping processing of the LSM hooks. However, the reliance on the individual LSMs to either call the capability hooks themselves, or signal the LSM with a return value of 1, is fragile and relies on a specific set of LSMs being enabled. This patch is an effort to resolve, or minimize, these issues.
Before we discuss the solution, there are a few observations and considerations that we need to take into account:
* BPF LSM registers an implementation for every LSM hook, and that implementation simply returns the hook's default return value, a 0 in this case. We want to ensure that the default BPF LSM behavior results in the capability checks being called.
* SELinux and Smack do not expect the traditional capability checks to be applied to the xattrs that they "own".
* SELinux and Smack are currently written in such a way that the xattr capability checks happen before any additional LSM specific access control checks. SELinux does apply SELinux specific access controls to all xattrs, even those not "owned" by SELinux.
* IMA and EVM also register xattr hooks but assume that the LSM layer and specific LSMs have already authorized the basic xattr operation.
In order to ensure we perform the capability based access controls before the individual LSM access controls, perform only one capability access control check for each operation, and clarify the logic around applying the capability controls, we need a mechanism to determine if any of the enabled LSMs "own" a particular xattr and want to take responsibility for controlling access to that xattr. The solution in this patch is to create a new LSM hook, 'inode_xattr_skipcap', that is not exported to the rest of the kernel via a security_XXX() function, but is used by the LSM layer to determine if a LSM wants to control access to a given xattr and avoid the traditional capability controls. Registering an inode_xattr_skipcap hook is optional, if a LSM declines to register an implementation, or uses an implementation that simply returns the default value (0), there is no effect as the LSM continues to enforce the capability based controls (unless another LSM takes ownership of the xattr). If none of the LSMs signal that the capability checks should be skipped, the capability check is performed and if access is granted the individual LSM xattr access control hooks are executed, keeping with the DAC-before-LSM convention.
--- include/linux/lsm_hook_defs.h | 1 security/security.c | 70 ++++++++++++++++++++++++++++-------------- security/selinux/hooks.c | 28 ++++++++++++---- security/smack/smack_lsm.c | 31 +++++++++++++++++- 4 files changed, 98 insertions(+), 32 deletions(-)
include/linux/lsm_hook_defs.h +1 -0
@@ -144,6 +144,7 @@ LSM_HOOK(int, 0, inode_setattr, struct m LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap, struct dentry *dentry, int ia_valid) LSM_HOOK(int, 0, inode_getattr, const struct path *path) +LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name) LSM_HOOK(int, 0, inode_setxattr, struct mnt_idmap *idmap, struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
security/security.c +48 -22
101 lines not on this page · raw message
security/selinux/hooks.c +20 -8
@@ -3177,6 +3177,23 @@ static bool has_cap_mac_admin(bool auditreturn true; } +/** +* selinux_inode_xattr_skipcap - Skip the xattr capability checks? +* @name: name of the xattr +* +* Returns 1 to indicate that SELinux "owns" the access control rights to xattrs +* named @name; the LSM layer should avoid enforcing any traditional +* capability based access controls on this xattr. Returns 0 to indicate that +* SELinux does not "own" the access control rights to xattrs named @name and is +* deferring to the LSM layer for further access controls, including capability +* based controls. +*/ +static int selinux_inode_xattr_skipcap (const char *name) +{ +/* require capability check if not a selinux xattr */ +return !strcmp (name,XATTR_NAME_SELINUX ); +} +static int selinux_inode_setxattr (struct mnt_idmap *idmap,struct dentry *dentry,const char *name,const void *value,size_t size,int flags)
@@ -3188,15 +3205,9 @@ static int selinux_inode_setxattr(structu32 newsid, sid =current_sid ();int rc =0 ; -if (strcmp (name,XATTR_NAME_SELINUX )) { - rc =cap_inode_setxattr (dentry, name, value, size, flags); -if (rc) -return rc; - -/* Not an attribute we recognize, so just check the -ordinary setattr permission. */ +/* if not a selinux xattr, only check the ordinary setattr perm */ +if (strcmp (name,XATTR_NAME_SELINUX ))return dentry_has_perm (current_cred (), dentry,FILE__SETATTR ); - }if (!selinux_initialized ())return (inode_owner_or_capable (idmap, inode) ?0 : -EPERM );
@@ -7175,6 +7186,7 @@ static struct security_hook_list selinuxLSM_HOOK_INIT (inode_permission, selinux_inode_permission),LSM_HOOK_INIT (inode_setattr, selinux_inode_setattr),LSM_HOOK_INIT (inode_getattr, selinux_inode_getattr), +LSM_HOOK_INIT (inode_xattr_skipcap, selinux_inode_xattr_skipcap),LSM_HOOK_INIT (inode_setxattr, selinux_inode_setxattr),LSM_HOOK_INIT (inode_post_setxattr, selinux_inode_post_setxattr), LSM_HOOK_INIT(inode_getxattr, selinux_inode_getxattr),
security/smack/smack_lsm.c +29 -2
@@ -1283,6 +1283,33 @@ static int smack_inode_getattr(const str }/** +* smack_inode_xattr_skipcap - Skip the xattr capability checks? +* @name: name of the xattr +* +* Returns 1 to indicate that Smack "owns" the access control rights to xattrs +* named @name; the LSM layer should avoid enforcing any traditional +* capability based access controls on this xattr. Returns 0 to indicate that +* Smack does not "own" the access control rights to xattrs named @name and is +* deferring to the LSM layer for further access controls, including capability +* based controls. +*/ +static int smack_inode_xattr_skipcap (const char *name) +{ +if (strncmp (name,XATTR_SMACK_SUFFIX ,strlen (XATTR_SMACK_SUFFIX ))) +return 0 ; + +if (strcmp (name,XATTR_NAME_SMACK ) ==0 || +strcmp (name,XATTR_NAME_SMACKIPIN ) ==0 || +strcmp (name,XATTR_NAME_SMACKIPOUT ) ==0 || +strcmp (name,XATTR_NAME_SMACKEXEC ) ==0 || +strcmp (name,XATTR_NAME_SMACKMMAP ) ==0 || +strcmp (name,XATTR_NAME_SMACKTRANSMUTE ) ==0 ) +return 1 ; + +return 0 ; +} + +/** * smack_inode_setxattr - Smack check for setting xattrs * @idmap: idmap of the mount * @dentry: the object
@@ -1325,8 +1352,7 @@ static int smack_inode_setxattr(struct m size != TRANS_TRUE_SIZE || strncmp(value, TRANS_TRUE, TRANS_TRUE_SIZE) != 0) rc = -EINVAL ; - }else - rc =cap_inode_setxattr (dentry, name, value, size, flags); + }if (check_priv && !smack_privileged (CAP_MAC_ADMIN )) rc = -EPERM ;
@@ -5053,6 +5079,7 @@ static struct security_hook_list smack_hLSM_HOOK_INIT (inode_permission, smack_inode_permission),LSM_HOOK_INIT (inode_setattr, smack_inode_setattr),LSM_HOOK_INIT (inode_getattr, smack_inode_getattr), +LSM_HOOK_INIT (inode_xattr_skipcap, smack_inode_xattr_skipcap),LSM_HOOK_INIT (inode_setxattr, smack_inode_setxattr),LSM_HOOK_INIT (inode_post_setxattr, smack_inode_post_setxattr), LSM_HOOK_INIT(inode_getxattr, smack_inode_getxattr),
Greg Kroah-Hartman
maintainerPATCH 577/809 io_uring/io-wq: limit retrying worker initialisation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 0453aad676ff99787124b9b3af4a5f59fbe808e2 upstream.
If io-wq worker creation fails, we retry it by queueing up a task_work. tasK_work is needed because it should be done from the user process context. The problem is that retries are not limited, and if queueing a task_work is the reason for the failure, we might get into an infinite loop.
It doesn't seem to happen now but it would with the following patch executing task_work in the freezer's loop. For now, arbitrarily limit the number of attempts to create a worker.
--- io_uring/io-wq.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
io_uring/io-wq.c +7 -3
@@ -23,6 +23,7 @@#include "io_uring.h" #define WORKER_IDLE_TIMEOUT (5 * HZ) +#define WORKER_INIT_LIMIT 3enum {IO_WORKER_F_UP =0 ,/* up and active */
@@ -58,6 +59,7 @@ struct io_worker {unsigned long create_state;struct callback_head create_work; +int init_retries;union {struct rcu_head rcu;
@@ -744,7 +746,7 @@ static bool io_wq_work_match_all(structreturn true; } -static inline bool io_should_retry_thread (long err) +static inline bool io_should_retry_thread (struct io_worker *worker,long err) {/* * Prevent perpetual task_work retry, if the task (or its group) is
@@ -752,6 +754,8 @@ static inline bool io_should_retry_threa*/ if (fatal_signal_pending (current))return false; +if (worker->init_retries++ >=WORKER_INIT_LIMIT ) +return false;switch (err) {case -EAGAIN :
@@ -778,7 +782,7 @@ static void create_worker_cont(struct caio_init_new_worker (wq, worker, tsk);io_worker_release (worker);return ; - }else if (!io_should_retry_thread (PTR_ERR (tsk))) { + }else if (!io_should_retry_thread (worker,PTR_ERR (tsk))) {struct io_wq_acct *acct =io_wq_get_acct (worker);atomic_dec (&acct->nr_running);
@@ -845,7 +849,7 @@ fail: tsk =create_io_thread (io_wq_worker, worker,NUMA_NO_NODE );if (!IS_ERR (tsk)) {io_init_new_worker (wq, worker, tsk); - }else if (!io_should_retry_thread (PTR_ERR (tsk))) { + }else if (!io_should_retry_thread (worker,PTR_ERR (tsk))) {kfree (worker); goto fail; }else {
Greg Kroah-Hartman
maintainerPATCH 578/809 drm/gma500: fix null pointer dereference in cdv_intel_lvds_get_modes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit cb520c3f366c77e8d69e4e2e2781a8ce48d98e79 upstream.
In cdv_intel_lvds_get_modes(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.
--- drivers/gpu/drm/gma500/cdv_intel_lvds.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/cdv_intel_lvds.c +3 -0
@@ -311,6 +311,9 @@ static int cdv_intel_lvds_get_modes(struif (mode_dev->panel_fixed_mode !=NULL ) {struct drm_display_mode *mode =drm_mode_duplicate (dev, mode_dev->panel_fixed_mode); +if (!mode) +return 0 ; +drm_mode_probed_add (connector, mode);return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 579/809 drm/gma500: fix null pointer dereference in psb_intel_lvds_get_modes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 2df7aac81070987b0f052985856aa325a38debf6 upstream.
In psb_intel_lvds_get_modes(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a possible NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.
--- drivers/gpu/drm/gma500/psb_intel_lvds.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/psb_intel_lvds.c +3 -0
@@ -504,6 +504,9 @@ static int psb_intel_lvds_get_modes(struif (mode_dev->panel_fixed_mode !=NULL ) {struct drm_display_mode *mode =drm_mode_duplicate (dev, mode_dev->panel_fixed_mode); +if (!mode) +return 0 ; +drm_mode_probed_add (connector, mode);return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 580/809 drm/amd/display: fix corruption with high refresh rates on DCN 3.0
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit e3615bd198289f319172c428f20857accb46b830 upstream.
This reverts commit bc87d666c05a13e6d4ae1ddce41fc43d2567b9a2 and the register changes from commit 6d4279cb99ac4f51d10409501d29969f687ac8dc.
--- drivers/gpu/drm/amd/display/dc/optc/dcn10/dcn10_optc.c | 15 +++------------ drivers/gpu/drm/amd/display/dc/optc/dcn20/dcn20_optc.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/dc/optc/dcn10/dcn10_optc.c +3 -12
@@ -945,19 +945,10 @@ void optc1_set_drr(OTG_FORCE_LOCK_ON_EVENT ,0 ,OTG_SET_V_TOTAL_MIN_MASK_EN ,0 , OTG_SET_V_TOTAL_MIN_MASK, 0); - -// Setup manual flow control for EOF via TRIG_A - optc->funcs->setup_manual_trigger (optc); - - }else { -REG_UPDATE_4 (OTG_V_TOTAL_CONTROL , -OTG_SET_V_TOTAL_MIN_MASK ,0 , -OTG_V_TOTAL_MIN_SEL ,0 , -OTG_V_TOTAL_MAX_SEL ,0 , -OTG_FORCE_LOCK_ON_EVENT ,0 ); - - optc->funcs->set_vtotal_min_max (optc,0 ,0 ); } + +// Setup manual flow control for EOF via TRIG_A + optc->funcs->setup_manual_trigger (optc); }void optc1_set_vtotal_min_max (struct timing_generator *optc,int vtotal_min,int vtotal_max)
drivers/gpu/drm/amd/display/dc/optc/dcn20/dcn20_optc.c +10 -0
@@ -462,6 +462,16 @@ void optc2_setup_manual_trigger(struct t {struct optc *optc1 =DCN10TG_FROM_TG (optc); +/* Set the min/max selectors unconditionally so that +* DMCUB fw may change OTG timings when necessary +* TODO: Remove the w/a after fixing the issue in DMCUB firmware +*/ +REG_UPDATE_4 (OTG_V_TOTAL_CONTROL , +OTG_V_TOTAL_MIN_SEL ,1 , +OTG_V_TOTAL_MAX_SEL ,1 , +OTG_FORCE_LOCK_ON_EVENT ,0 , +OTG_SET_V_TOTAL_MIN_MASK , (1 <<1 ));/* TRIGA */ + REG_SET_8(OTG_TRIGA_CNTL, 0, OTG_TRIGA_SOURCE_SELECT, 21, OTG_TRIGA_SOURCE_PIPE_SELECT, optc->inst,
Greg Kroah-Hartman
maintainerPATCH 581/809 scsi: qla2xxx: Fix optrom version displayed in FDMI
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shreyas Deodhar <[email protected]>
commit 348744f27a35e087acc9378bf53537fbfb072775 upstream.
Bios version was popluated for FDMI response. Systems with EFI would show optrom version as 0. EFI version is populated here and BIOS version is already displayed under FDMI_HBA_BOOT_BIOS_NAME.
--- drivers/scsi/qla2xxx/qla_gs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_gs.c +1 -1
@@ -1710,7 +1710,7 @@ qla2x00_hba_attributes(scsi_qla_host_t * eiter->type =cpu_to_be16 (FDMI_HBA_OPTION_ROM_VERSION ); alen =scnprintf ( eiter->a.orom_version,sizeof (eiter->a.orom_version), -"%d.%02d" , ha->bios_revision[1 ], ha->bios_revision[0 ]); +"%d.%02d" , ha->efi_revision[1 ], ha->efi_revision[0 ]); alen +=FDMI_ATTR_ALIGNMENT (alen); alen +=FDMI_ATTR_TYPELEN (eiter); eiter->len =cpu_to_be16 (alen);
Greg Kroah-Hartman
maintainerPATCH 582/809 drm/amd/display: Check for NULL pointer
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Joon Kim <[email protected]>
commit 4ab68e168ae1695f7c04fae98930740aaf7c50fa upstream.
[why & how]
Need to make sure plane_state is initialized
before accessing its members.
--- drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_surface.c +2 -1
@@ -143,7 +143,8 @@ const struct dc_plane_status *dc_plane_gif (pipe_ctx->plane_state != plane_state)continue ; - pipe_ctx->plane_state->status.is_flip_pending = false; +if (pipe_ctx->plane_state) + pipe_ctx->plane_state->status.is_flip_pending = false;break ; }
Greg Kroah-Hartman
maintainerPATCH 583/809 apparmor: use kvfree_sensitive to free data->data
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit 2bc73505a5cd2a18a7a542022722f136c19e3b87 upstream.
Inside unpack_profile() data->data is allocated using kvmemdup() so it should be freed with the corresponding kvfree_sensitive().
Also add missing data->data release for rhashtable insertion failure path in unpack_profile().
Found by Linux Verification Center (linuxtesting.org).
--- security/apparmor/policy.c | 2 +- security/apparmor/policy_unpack.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
security/apparmor/policy.c +1 -1
@@ -225,7 +225,7 @@ static void aa_free_data(void *ptr, void {struct aa_data *data = ptr; -kfree_sensitive (data->data); +kvfree_sensitive (data->data, data->size);kfree_sensitive (data->key);kfree_sensitive (data); }
security/apparmor/policy_unpack.c +1 -0
@@ -1071,6 +1071,7 @@ static struct aa_profile *unpack_profileif (rhashtable_insert_fast (profile->data, &data->head, profile->data->p)) { +kvfree_sensitive (data->data, data->size);kfree_sensitive (data->key);kfree_sensitive (data); info ="failed to insert data to table" ;
Greg Kroah-Hartman
maintainerPATCH 584/809 cifs: fix potential null pointer use in destroy_workqueue in init_cifs error path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 193cc89ea0ca1da311877d2b4bb5e9f03bcc82a2 upstream.
Dan Carpenter reported a Smack static checker warning:
fs/smb/client/cifsfs.c:1981 init_cifs()
error: we previously assumed 'serverclose_wq' could be null (see line 1895)
The patch which introduced the serverclose workqueue used the wrong oredering in error paths in init_cifs() for freeing it on errors.
--- fs/smb/client/cifsfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/smb/client/cifsfs.c +4 -4
@@ -1894,12 +1894,12 @@ init_cifs(void) WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);if (!serverclose_wq) { rc = -ENOMEM ; - goto out_destroy_serverclose_wq; + goto out_destroy_deferredclose_wq; } rc =cifs_init_inodecache ();if (rc) - goto out_destroy_deferredclose_wq; + goto out_destroy_serverclose_wq; rc =cifs_init_netfs ();if (rc)
@@ -1967,6 +1967,8 @@ out_destroy_netfs:cifs_destroy_netfs (); out_destroy_inodecache:cifs_destroy_inodecache (); +out_destroy_serverclose_wq: +destroy_workqueue (serverclose_wq); out_destroy_deferredclose_wq:destroy_workqueue (deferredclose_wq); out_destroy_cifsoplockd_wq:
@@ -1977,8 +1979,6 @@ out_destroy_decrypt_wq:destroy_workqueue (decrypt_wq); out_destroy_cifsiod_wq:destroy_workqueue (cifsiod_wq); -out_destroy_serverclose_wq: -destroy_workqueue (serverclose_wq); out_clean_proc:cifs_proc_clean ();return rc;
Greg Kroah-Hartman
maintainerPATCH 585/809 cifs: fix reconnect with SMB1 UNIX Extensions
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit a214384ce26b6111ea8c8d58fa82a1ca63996c38 upstream.
When mounting with the SMB1 Unix Extensions (e.g. mounts to Samba with vers=1.0), reconnects no longer reset the Unix Extensions (SetFSInfo SET_FILE_UNIX_BASIC) after tcon so most operations (e.g. stat, ls, open, statfs) will fail continuously with:
"Operation not supported"
if the connection ever resets (e.g. due to brief network disconnect)
--- fs/smb/client/connect.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
fs/smb/client/connect.c +16 -1
@@ -3686,6 +3686,7 @@ error: }#endif +#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY /* * Issue a TREE_CONNECT request. */
@@ -3807,11 +3808,25 @@ CIFSTCon(const unsigned int xid, struct else tcon->Flags = 0;cifs_dbg (FYI ,"Tcon flags: 0x%x\n" , tcon->Flags); - } +/* +* reset_cifs_unix_caps calls QFSInfo which requires +* need_reconnect to be false, but we would not need to call +* reset_caps if this were not a reconnect case so must check +* need_reconnect flag here. The caller will also clear +* need_reconnect when tcon was successful but needed to be +* cleared earlier in the case of unix extensions reconnect +*/ +if (tcon->need_reconnect && tcon->unix_ext) { +cifs_dbg (FYI ,"resetting caps for %s\n" , tcon->tree_name); + tcon->need_reconnect = false; +reset_cifs_unix_caps (xid, tcon,NULL ,NULL ); + } + }cifs_buf_release (smb_buffer);return rc; } +#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ static void delayed_free (struct rcu_head *p) {
Greg Kroah-Hartman
maintainerPATCH 586/809 cifs: mount with "unix" mount option for SMB1 incorrectly handled
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 0e314e452687ce0ec5874e42cdb993a34325d3d2 upstream.
Although by default we negotiate CIFS Unix Extensions for SMB1 mounts to Samba (and they work if the user does not specify "unix" or "posix" or "linux" on mount), and we do properly handle when a user turns them off with "nounix" mount parm. But with the changes to the mount API we broke cases where the user explicitly specifies the "unix" option (or equivalently "linux" or "posix") on mount with vers=1.0 to Samba or other servers which support the CIFS Unix Extensions.
"mount error(95): Operation not supported"
and logged:
"CIFS: VFS: Check vers= mount option. SMB3.11 disabled but required for POSIX extensions"
even though CIFS Unix Extensions are supported for vers=1.0 This patch fixes the case where the user specifies both "unix" (or equivalently "posix" or "linux") and "vers=1.0" on mount to a server which supports the CIFS Unix Extensions.
--- fs/smb/client/connect.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/smb/client/connect.c +7 -0
@@ -2614,6 +2614,13 @@ cifs_get_tcon(struct cifs_ses *ses, strucifs_dbg (VFS ,"Server does not support mounting with posix SMB3.11 extensions\n" ); rc = -EOPNOTSUPP ; goto out_fail; + }else if (ses->server->vals->protocol_id ==SMB10_PROT_ID ) +if (cap_unix (ses)) +cifs_dbg (FYI ,"Unix Extensions requested on SMB1 mount\n" ); +else { +cifs_dbg (VFS ,"SMB1 Unix Extensions not supported by server\n" ); + rc = -EOPNOTSUPP ; + goto out_fail; }else {cifs_dbg (VFS ,"Check vers= mount option. SMB3.11 disabled but required for POSIX extensions\n" );
Greg Kroah-Hartman
maintainerPATCH 587/809 task_work: s/task_work_cancel()/task_work_cancel_func()/
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
commit 68cbd415dd4b9c5b9df69f0f091879e56bf5907a upstream.
A proper task_work_cancel() API that actually cancels a callback and not *any* callback pointing to a given function is going to be needed for perf events event freeing. Do the appropriate rename to prepare for that.
--- include/linux/task_work.h | 2 +- kernel/irq/manage.c | 2 +- kernel/task_work.c | 10 +++++----- security/keys/keyctl.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
include/linux/task_work.h +1 -1
@@ -30,7 +30,7 @@ int task_work_add(struct task_struct *tastruct callback_head *task_work_cancel_match (struct task_struct *task,bool (*match)(struct callback_head *,void *data),void *data); -struct callback_head *task_work_cancel (struct task_struct *,task_work_func_t ); +struct callback_head *task_work_cancel_func (struct task_struct *,task_work_func_t );void task_work_run (void );static inline void exit_task_work (struct task_struct *task)
kernel/irq/manage.c +1 -1
@@ -1337,7 +1337,7 @@ static int irq_thread(void *data)* synchronize_hardirq(). So neither IRQTF_RUNTHREAD nor the * oneshot mask bit can be set. */ -task_work_cancel (current, irq_thread_dtor); +task_work_cancel_func (current, irq_thread_dtor);return 0 ; }
kernel/task_work.c +5 -5
@@ -120,9 +120,9 @@ static bool task_work_func_match(struct }/** -* task_work_cancel - cancel a pending work added by task_work_add() -* @task: the task which should execute the work -* @func: identifies the work to remove +* task_work_cancel_func - cancel a pending work matching a function added by task_work_add() +* @task: the task which should execute the func's work +* @func: identifies the func to match with a work to remove * * Find the last queued pending work with ->func == @func and remove * it from queue.
@@ -131,7 +131,7 @@ static bool task_work_func_match(struct* The found work or NULL if not found. */ struct callback_head * -task_work_cancel (struct task_struct *task,task_work_func_t func) +task_work_cancel_func (struct task_struct *task,task_work_func_t func) {return task_work_cancel_match (task, task_work_func_match, func); }
@@ -168,7 +168,7 @@ void task_work_run(void)if (!work)break ;/* -* Synchronize with task_work_cancel(). It can not remove +* Synchronize with task_work_cancel_match(). It can not remove * the first entry == work, cmpxchg(task_works) must fail. * But it can remove another entry from the ->next list. */
security/keys/keyctl.c +1 -1
@@ -1694,7 +1694,7 @@ long keyctl_session_to_parent(void) goto unlock;/* cancel an already pending keyring replacement */ - oldwork =task_work_cancel (parent, key_change_session_keyring); + oldwork =task_work_cancel_func (parent, key_change_session_keyring);/* the replacement session keyring is applied just prior to userspace * restarting */
Greg Kroah-Hartman
maintainerPATCH 588/809 task_work: Introduce task_work_cancel() again
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
commit f409530e4db9dd11b88cb7703c97c8f326ff6566 upstream.
Re-introduce task_work_cancel(), this time to cancel an actual callback and not *any* callback pointing to a given function. This is going to be needed for perf events event freeing.
--- include/linux/task_work.h | 1 + kernel/task_work.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)
include/linux/task_work.h +1 -0
@@ -31,6 +31,7 @@ int task_work_add(struct task_struct *tastruct callback_head *task_work_cancel_match (struct task_struct *task,bool (*match)(struct callback_head *,void *data),void *data);struct callback_head *task_work_cancel_func (struct task_struct *,task_work_func_t ); +bool task_work_cancel (struct task_struct *task,struct callback_head *cb);void task_work_run (void );static inline void exit_task_work (struct task_struct *task)
kernel/task_work.c +24 -0
@@ -136,6 +136,30 @@ task_work_cancel_func(struct task_structreturn task_work_cancel_match (task, task_work_func_match, func); } +static bool task_work_match (struct callback_head *cb,void *data) +{ +return cb == data; +} + +/** +* task_work_cancel - cancel a pending work added by task_work_add() +* @task: the task which should execute the work +* @cb: the callback to remove if queued +* +* Remove a callback from a task's queue if queued. +* +* RETURNS: +* True if the callback was queued and got cancelled, false otherwise. +*/ +bool task_work_cancel (struct task_struct *task,struct callback_head *cb) +{ +struct callback_head *ret; + + ret =task_work_cancel_match (task, task_work_match, cb); + +return ret == cb; +} +/** * task_work_run - execute the works added by task_work_add() *
Greg Kroah-Hartman
maintainerPATCH 589/809 udf: Avoid using corrupted block bitmap buffer
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit a90d4471146de21745980cba51ce88e7926bcc4f upstream.
When the filesystem block bitmap is corrupted, we detect the corruption while loading the bitmap and fail the allocation with error. However the next allocation from the same bitmap will notice the bitmap buffer is already loaded and tries to allocate from the bitmap with mixed results (depending on the exact nature of the bitmap corruption). Fix the problem by using BH_verified bit to indicate whether the bitmap is valid or not.
--- fs/udf/balloc.c | 15 +++++++++++++-- fs/udf/super.c | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-)
fs/udf/balloc.c +13 -2
@@ -64,8 +64,12 @@ static int read_block_bitmap(struct supe }for (i =0 ; i < count; i++) -if (udf_test_bit (i + off, bh->b_data)) +if (udf_test_bit (i + off, bh->b_data)) { + bitmap->s_block_bitmap[bitmap_nr] = +ERR_PTR (-EFSCORRUPTED ); +brelse (bh);return -EFSCORRUPTED ; + }return 0 ; }
@@ -81,8 +85,15 @@ static int __load_block_bitmap(struct su block_group, nr_groups); } -if (bitmap->s_block_bitmap[block_group]) +if (bitmap->s_block_bitmap[block_group]) { +/* +* The bitmap failed verification in the past. No point in +* trying again. +*/ +if (IS_ERR (bitmap->s_block_bitmap[block_group])) +return PTR_ERR (bitmap->s_block_bitmap[block_group]);return block_group; + } retval =read_block_bitmap (sb, bitmap, block_group, block_group);if (retval <0 )
fs/udf/super.c +2 -1
@@ -336,7 +336,8 @@ static void udf_sb_free_bitmap(struct udint nr_groups = bitmap->s_nr_groups;for (i =0 ; i < nr_groups; i++) -brelse (bitmap->s_block_bitmap[i]); +if (!IS_ERR_OR_NULL (bitmap->s_block_bitmap[i])) +brelse (bitmap->s_block_bitmap[i]);kvfree (bitmap); }
Greg Kroah-Hartman
maintainerPATCH 590/809 m68k: amiga: Turn off Warp1260 interrupts during boot
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Pisati <[email protected]>
commit 1d8491d3e726984343dd8c3cdbe2f2b47cfdd928 upstream.
On an Amiga 1200 equipped with a Warp1260 accelerator, an interrupt storm coming from the accelerator board causes the machine to crash in local_irq_enable() or auto_irq_enable(). Disabling interrupts for the Warp1260 in amiga_parse_bootinfo() fixes the problem.
--- arch/m68k/amiga/config.c | 9 +++++++++ include/uapi/linux/zorro_ids.h | 3 +++ 2 files changed, 12 insertions(+)
arch/m68k/amiga/config.c +9 -0
@@ -180,6 +180,15 @@ int __init amiga_parse_bootinfo(const st dev->slotsize =be16_to_cpu (cd->cd_SlotSize); dev->boardaddr =be32_to_cpu (cd->cd_BoardAddr); dev->boardsize =be32_to_cpu (cd->cd_BoardSize); + +/* CS-LAB Warp 1260 workaround */ +if (be16_to_cpu (dev->rom.er_Manufacturer) ==ZORRO_MANUF (ZORRO_PROD_CSLAB_WARP_1260 ) && + dev->rom.er_Product ==ZORRO_PROD (ZORRO_PROD_CSLAB_WARP_1260 )) { + +/* turn off all interrupts */ +pr_info ("Warp 1260 card detected: applying interrupt storm workaround\n" ); + *(uint32_t *)(dev->boardaddr +0x1000 ) =0xfff ; + } }else pr_warn ("amiga_parse_bootinfo: too many AutoConfig devices\n" );#endif /* CONFIG_ZORRO */
include/uapi/linux/zorro_ids.h +3 -0
@@ -449,6 +449,9 @@#define ZORRO_PROD_VMC_ISDN_BLASTER_Z2 ZORRO_ID(VMC, 0x01, 0)#define ZORRO_PROD_VMC_HYPERCOM_4 ZORRO_ID(VMC, 0x02, 0) +#define ZORRO_MANUF_CSLAB 0x1400 +#define ZORRO_PROD_CSLAB_WARP_1260 ZORRO_ID(CSLAB, 0x65, 0) +#define ZORRO_MANUF_INFORMATION 0x157C#define ZORRO_PROD_INFORMATION_ISDN_ENGINE_I ZORRO_ID(INFORMATION, 0x64, 0)
Greg Kroah-Hartman
maintainerPATCH 591/809 block: check bio alignment in blk_mq_submit_bio
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit 0676c434a99be42f3bacca4adfd27df65edbf903 upstream.
IO logical block size is one fundamental queue limit, and every IO has to be aligned with logical block size because our bio split can't deal with unaligned bio.
The check has to be done with queue usage counter grabbed because device reconfiguration may change logical block size, and we can prevent the reconfiguration from happening by holding queue usage counter.
logical_block_size stays in the 1st cache line of queue_limits, and this cache line is always fetched in fast path via bio_may_exceed_limits(), so IO perf won't be affected by this check.
--- block/blk-mq.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
block/blk-mq.c +20 -0
@@ -2914,6 +2914,17 @@ static void blk_mq_use_cached_rq(structINIT_LIST_HEAD (&rq->queuelist); } +static bool bio_unaligned (const struct bio *bio,struct request_queue *q) +{ +unsigned int bs_mask =queue_logical_block_size (q) -1 ; + +/* .bi_sector of any zero sized bio need to be initialized */ +if ((bio->bi_iter.bi_size & bs_mask) || + ((bio->bi_iter.bi_sector <<SECTOR_SHIFT ) & bs_mask)) +return true; +return false; +} +/** * blk_mq_submit_bio - Create and send a request to block device. * @bio: Bio pointer.
@@ -2966,6 +2977,15 @@ void blk_mq_submit_bio(struct bio *bio)return ; } +/* +* Device reconfiguration may change logical block size, so alignment +* check has to be done with queue usage counter held +*/ +if (unlikely (bio_unaligned (bio, q))) { +bio_io_error (bio); + goto queue_exit; + } +if (unlikely (bio_may_exceed_limits (bio, &q->limits))) { bio =__bio_split_to_limits (bio, &q->limits, &nr_segs);if (!bio)
Greg Kroah-Hartman
maintainerPATCH 592/809 ext4: check dot and dotdot of dx_root before making dir indexed
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 50ea741def587a64e08879ce6c6a30131f7111e7 upstream.
Syzbot reports a issue as follows:
============================================
BUG: unable to handle page fault for address: ffffed11022e24fe PGD 23ffee067 P4D 23ffee067 PUD 0 Oops: Oops: 0000 [#1] PREEMPT SMP KASAN PTI CPU: 0 PID: 5079 Comm: syz-executor306 Not tainted 6.10.0-rc5-g55027e689933 #0 Call Trace: <TASK> make_indexed_dir+0xdaf/0x13c0 fs/ext4/namei.c:2341 ext4_add_entry+0x222a/0x25d0 fs/ext4/namei.c:2451 ext4_rename fs/ext4/namei.c:3936 [inline] ext4_rename2+0x26e5/0x4370 fs/ext4/namei.c:4214
[...]
============================================
The immediate cause of this problem is that there is only one valid dentry for the block to be split during do_split, so split==0 results in out of bounds accesses to the map triggering the issue.
do_split
unsigned split
dx_make_map
count = 1
split = count/2 = 0;
continued = hash2 == map[split - 1].hash;
---> map[4294967295]The maximum length of a filename is 255 and the minimum block size is 1024, so it is always guaranteed that the number of entries is greater than or equal to 2 when do_split() is called.
But syzbot's crafted image has no dot and dotdot in dir, and the dentry distribution in dirblock is as follows:
bus dentry1 hole dentry2 free
|xx--|xx-------------|...............|xx-------------|...............| 0 12 (8+248)=256 268 256 524 (8+256)=264 788 236 1024
So when renaming dentry1 increases its name_len length by 1, neither hole nor free is sufficient to hold the new dentry, and make_indexed_dir() is called.
In make_indexed_dir() it is assumed that the first two entries of the dirblock must be dot and dotdot, so bus and dentry1 are left in dx_root because they are treated as dot and dotdot, and only dentry2 is moved to the new leaf block. That's why count is equal to 1.
Therefore add the ext4_check_dx_root() helper function to add more sanity checks to dot and dotdot before starting the conversion to avoid the above issue.
--- fs/ext4/namei.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-)
fs/ext4/namei.c +51 -5
@@ -2217,6 +2217,52 @@ static int add_dirent_to_buf(handle_t *hreturn err ? err : err2; } +static bool ext4_check_dx_root (struct inode *dir,struct dx_root *root) +{ +struct fake_dirent *fde; +const char *error_msg; +unsigned int rlen; +unsigned int blocksize = dir->i_sb->s_blocksize; +char *blockend = (char *)root + dir->i_sb->s_blocksize; + + fde = &root->dot; +if (unlikely (fde->name_len !=1 )) { + error_msg ="invalid name_len for '.'" ; + goto corrupted; + } +if (unlikely (strncmp (root->dot_name,"." , fde->name_len))) { + error_msg ="invalid name for '.'" ; + goto corrupted; + } + rlen =ext4_rec_len_from_disk (fde->rec_len, blocksize); +if (unlikely ((char *)fde + rlen >= blockend)) { + error_msg ="invalid rec_len for '.'" ; + goto corrupted; + } + + fde = &root->dotdot; +if (unlikely (fde->name_len !=2 )) { + error_msg ="invalid name_len for '..'" ; + goto corrupted; + } +if (unlikely (strncmp (root->dotdot_name,".." , fde->name_len))) { + error_msg ="invalid name for '..'" ; + goto corrupted; + } + rlen =ext4_rec_len_from_disk (fde->rec_len, blocksize); +if (unlikely ((char *)fde + rlen >= blockend)) { + error_msg ="invalid rec_len for '..'" ; + goto corrupted; + } + +return true; + +corrupted: +EXT4_ERROR_INODE (dir,"Corrupt dir, %s, running e2fsck is recommended" , + error_msg); +return false; +} +/* * This converts a one block unindexed directory to a 3 block indexed * directory, and adds the dentry to the indexed directory.
@@ -2251,17 +2297,17 @@ static int make_indexed_dir(handle_t *habrelse (bh);return retval; } + root = (struct dx_root *) bh->b_data; +if (!ext4_check_dx_root (dir, root)) { +brelse (bh); +return -EFSCORRUPTED ; + }/* The 0th block becomes the root, move the dirents out */ fde = &root->dotdot; de = (struct ext4_dir_entry_2 *)((char *)fde +ext4_rec_len_from_disk (fde->rec_len, blocksize)); -if ((char *) de >= (((char *) root) + blocksize)) { -EXT4_ERROR_INODE (dir,"invalid rec_len for '..'" ); -brelse (bh); -return -EFSCORRUPTED ; - } len = ((char *) root) + (blocksize - csum_size) - (char *) de;/* Allocate new block for the 0th block's dirents */
Greg Kroah-Hartman
maintainerPATCH 593/809 ext4: make sure the first directory block is not a hole
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit f9ca51596bbfd0f9c386dd1c613c394c78d9e5e6 upstream.
The syzbot constructs a directory that has no dirblock but is non-inline, i.e. the first directory block is a hole. And no errors are reported when creating files in this directory in the following flow.
ext4_mknod
...
ext4_add_entry
// Read block 0
ext4_read_dirblock(dir, block, DIRENT)
bh = ext4_bread(NULL, inode, block, 0)
if (!bh && (type == INDEX || type == DIRENT_HTREE))
// The first directory block is a hole
// But type == DIRENT, so no error is reported.After that, we get a directory block without '.' and '..' but with a valid dentry. This may cause some code that relies on dot or dotdot (such as make_indexed_dir()) to crash.
Therefore when ext4_read_dirblock() finds that the first directory block is a hole report that the filesystem is corrupted and return an error to avoid loading corrupted data from disk causing something bad.
--- fs/ext4/namei.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
fs/ext4/namei.c +6 -11
@@ -151,10 +151,11 @@ static struct buffer_head *__ext4_read_dreturn bh; } -if (!bh && (type ==INDEX || type ==DIRENT_HTREE )) { +/* The first directory block must not be a hole. */ +if (!bh && (type ==INDEX || type ==DIRENT_HTREE || block ==0 )) {ext4_error_inode (inode, func, line, block, -"Directory hole found for htree %s block" , - (type ==INDEX ) ?"index" :"leaf" ); +"Directory hole found for htree %s block %u" , + (type ==INDEX ) ?"index" :"leaf" , block);return ERR_PTR (-EFSCORRUPTED ); }if (!bh)
@@ -3129,10 +3130,7 @@ bool ext4_empty_dir(struct inode *inode)EXT4_ERROR_INODE (inode,"invalid size" );return false; } -/* The first directory block must not be a hole, -* so treat it as DIRENT_HTREE -*/ - bh =ext4_read_dirblock (inode,0 ,DIRENT_HTREE ); + bh =ext4_read_dirblock (inode,0 ,EITHER );if (IS_ERR (bh))return false;
@@ -3577,10 +3575,7 @@ static struct buffer_head *ext4_get_firsstruct ext4_dir_entry_2 *de;unsigned int offset; -/* The first directory block must not be a hole, so -* treat it as DIRENT_HTREE -*/ - bh =ext4_read_dirblock (inode,0 ,DIRENT_HTREE ); + bh =ext4_read_dirblock (inode,0 ,EITHER );if (IS_ERR (bh)) { *retval =PTR_ERR (bh);return NULL ;
Greg Kroah-Hartman
maintainerPATCH 594/809 io_uring: fix lost getsockopt completions
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 24dce1c538a7ceac43f2f97aae8dfd4bb93ea9b9 upstream.
There is a report that iowq executed getsockopt never completes. The reason being that io_uring_cmd_sock() can return a positive result, and io_uring_cmd() propagates it back to core io_uring, instead of IOU_OK. In case of io_wq_submit_work(), the request will be dropped without completing it.
The offending code was introduced by a hack ina9c3eda7eada9 ("io_uring: fix submission-failure handling for uring-cmd"), however it was fine until getsockopt was introduced and started returning positive results.
The right solution is to always return IOU_OK, since e0b23d9953b0c ("io_uring: optimise ltimeout for inline execution"), we should be able to do it without problems, however for the sake of backporting and minimising side effects, let's keep returning negative return codes and otherwise do IOU_OK.
--- io_uring/uring_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/uring_cmd.c +1 -1
@@ -265,7 +265,7 @@ int io_uring_cmd(struct io_kiocb *req, ureq_set_fail (req);io_req_uring_cleanup (req, issue_flags);io_req_set_res (req, ret,0 ); -return ret; +return ret <0 ? ret :IOU_OK ; } int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
Greg Kroah-Hartman
maintainerPATCH 595/809 io_uring: tighten task exit cancellations
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit f8b632e89a101dae349a7b212c1771d7925f441b upstream.
io_uring_cancel_generic() should retry if any state changes like a request is completed, however in case of a task exit it only goes for another loop and avoids schedule() if any tracked (i.e. REQ_F_INFLIGHT) request got completed.
Let's assume we have a non-tracked request executing in iowq and a tracked request linked to it. Let's also assume io_uring_cancel_generic() fails to find and cancel the request, i.e. via io_run_local_work(), which may happen as io-wq has gaps. Next, the request logically completes, io-wq still hold a ref but queues it for completion via tw, which happens in io_uring_try_cancel_requests(). After, right before prepare_to_wait() io-wq puts the request, grabs the linked one and tries executes it, e.g. arms polling. Finally the cancellation loop calls prepare_to_wait(), there are no tw to run, no tracked request was completed, so the tctx_inflight() check passes and the task is put to indefinite sleep.
--- io_uring/io_uring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
io_uring/io_uring.c +4 -1
@@ -3071,8 +3071,11 @@ __cold void io_uring_cancel_generic(boolbool loop = false;io_uring_drop_tctx_refs (current); +if (!tctx_inflight (tctx, !cancel_all)) +break ; +/* read completions before cancelations */ - inflight =tctx_inflight (tctx, !cancel_all); + inflight =tctx_inflight (tctx, false);if (!inflight)break ;
Greg Kroah-Hartman
maintainerPATCH 596/809 io_uring: dont allow netpolling with SETUP_IOPOLL
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit bd44d7e902c2b34c217d3b48874b079760ca7b6e upstream.
IORING_SETUP_IOPOLL rings don't have any netpoll handling, let's fail attempts to register netpolling in this case, there might be people who will mix up IOPOLL and netpoll.
--- io_uring/napi.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/napi.c +2 -0
@@ -222,6 +222,8 @@ int io_register_napi(struct io_ring_ctx };struct io_uring_napi napi; +if (ctx->flags &IORING_SETUP_IOPOLL ) +return -EINVAL ;if (copy_from_user (&napi, arg,sizeof (napi)))return -EFAULT ;if (napi.pad[0 ] || napi.pad[1 ] || napi.pad[2 ] || napi.resv)
Greg Kroah-Hartman
maintainerPATCH 597/809 trace/pid_list: Change gfp flags in pid_list_fill_irq()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: levi.yun <[email protected]>
commit 7dc836187f7c6f70a82b4521503e9f9f96194581 upstream.
pid_list_fill_irq() runs via irq_work.
When CONFIG_PREEMPT_RT is disabled, it would run in irq_context. so it shouldn't sleep while memory allocation.
Change gfp flags from GFP_KERNEL to GFP_NOWAIT to prevent sleep in irq_work.
This change wouldn't impact functionality in practice because the worst-size is 2K.
--- kernel/trace/pid_list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/pid_list.c +2 -2
@@ -354,7 +354,7 @@ static void pid_list_refill_irq(struct iwhile (upper_count-- >0 ) {union upper_chunk *chunk; - chunk =kzalloc (sizeof (*chunk),GFP_KERNEL ); + chunk =kzalloc (sizeof (*chunk),GFP_NOWAIT );if (!chunk)break ; *upper_next = chunk;
@@ -365,7 +365,7 @@ static void pid_list_refill_irq(struct iwhile (lower_count-- >0 ) {union lower_chunk *chunk; - chunk =kzalloc (sizeof (*chunk),GFP_KERNEL ); + chunk =kzalloc (sizeof (*chunk),GFP_NOWAIT );if (!chunk)break ; *lower_next = chunk;
Greg Kroah-Hartman
maintainerPATCH 598/809 genirq: Set IRQF_COND_ONESHOT in request_irq()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit c37927a203fa283950f6045602b9f71328ad786c upstream.
The callers of request_irq() don't care about IRQF_ONESHOT because they don't provide threaded handlers, but if they happen to share the IRQ with the ACPI SCI, which has a threaded handler and sets IRQF_ONESHOT, request_irq() will fail for them due to a flags mismatch.
Address this by making request_irq() add IRQF_COND_ONESHOT to the flags passed to request_threaded_irq() for all of its callers.
--- include/linux/interrupt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/interrupt.h +1 -1
@@ -168,7 +168,7 @@ static inline int __must_check request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev) { - return request_threaded_irq(irq, handler, NULL, flags, name, dev); + return request_threaded_irq(irq, handler, NULL, flags | IRQF_COND_ONESHOT, name, dev); } extern int __must_check
Signature · 1 line
2.45.2
Greg Kroah-Hartman
maintainerPATCH 599/809 wifi: mwifiex: Fix interface type change
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael Beims <[email protected]>
commit a17b9f590f6ec2b9f1b12b1db3bf1d181de6b272 upstream.
When changing the interface type we also need to update the bss_num, the driver private data is searched based on a unique (bss_type, bss_num) tuple, therefore every time bss_type changes, bss_num must also change.
This fixes for example an issue in which, after the mode changed, a wireless scan on the changed interface would not finish, leading to repeated -EBUSY messages to userspace when other scan requests were sent.
--- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/marvell/mwifiex/cfg80211.c +2 -0
@@ -926,6 +926,8 @@ mwifiex_init_new_priv_params(struct mwifreturn -EOPNOTSUPP ; } + priv->bss_num =mwifiex_get_unused_bss_num (adapter, priv->bss_type); +spin_lock_irqsave (&adapter->main_proc_lock, flags); adapter->main_locked = false;spin_unlock_irqrestore (&adapter->main_proc_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 600/809 wifi: rtw89: fix HW scan not aborting properly
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Po-Hao Huang <[email protected]>
commit 669b692247d4516e252c898c0e7366a09d84d1be upstream.
There is a length limit on the commands we send to firmware, so dividing to two commands is sometimes required when scanning. When aborting scan, we should not send second scan command to firmware after the first one is finished. This could cause some unexpected errors when we cannot receive firmware events (e.g. in suspend).
Another case is scan happens before suspending, ieee80211_do_stop() is called to abort scan and driver indicate scan completion by ieee80211_scan_completed(), which queues event to scan work. But scan work might be late to execute after ieee80211_do_stop(). To correct this, driver indicates ieee80211_scan_completed() before returning, so that ieee80211_do_stop() can flush scan work properly.
--- drivers/net/wireless/realtek/rtw89/fw.c | 9 ++++++++- drivers/net/wireless/realtek/rtw89/mac.c | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/fw.c +8 -1
@@ -6245,7 +6245,14 @@ void rtw89_hw_scan_abort(struct rtw89_de ret =rtw89_hw_scan_offload (rtwdev, vif, false);if (ret) -rtw89_hw_scan_complete (rtwdev, vif, true); +rtw89_warn (rtwdev,"rtw89_hw_scan_offload failed ret %d\n" , ret); + +/* Indicate ieee80211_scan_completed() before returning, which is safe +* because scan abort command always waits for completion of +* RTW89_SCAN_END_SCAN_NOTIFY, so that ieee80211_stop() can flush scan +* work properly. +*/ +rtw89_hw_scan_complete (rtwdev, vif, true); }static bool rtw89_is_any_vif_connected_or_connecting (struct rtw89_dev *rtwdev)
drivers/net/wireless/realtek/rtw89/mac.c +4 -1
@@ -4757,6 +4757,9 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_ }return ;case RTW89_SCAN_END_SCAN_NOTIFY : +if (rtwdev->scan_info.abort) +return ; +if (rtwvif && rtwvif->scan_req && last_chan < rtwvif->scan_req->n_channels) { ret =rtw89_hw_scan_offload (rtwdev, vif, true);
@@ -4765,7 +4768,7 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_rtw89_warn (rtwdev,"HW scan failed: %d\n" , ret); } }else { -rtw89_hw_scan_complete (rtwdev, vif, rtwdev->scan_info.abort); +rtw89_hw_scan_complete (rtwdev, vif, false); }break ;case RTW89_SCAN_ENTER_OP_NOTIFY :
Greg Kroah-Hartman
maintainerPATCH 601/809 wifi: rtw88: usb: Fix disconnection after beacon loss
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit 28818b4d871bc93cc4f5c7c7d7c526a6a096c09c upstream.
When there is beacon loss, for example due to unrelated Bluetooth devices transmitting music nearby, the wifi connection dies soon after the first beacon loss message:
Apr 28 20:47:14 ideapad2 wpa_supplicant[1161]: wlp3s0f3u4: CTRL-EVENT-BEACON-LOSS Apr 28 20:47:15 ideapad2 wpa_supplicant[1161]: wlp3s0f3u4: CTRL-EVENT-DISCONNECTED bssid=... reason=4 locally_generated=1
Apr 28 20:47:24 ideapad2 wpa_supplicant[1161]: wlp3s0f3u4: CTRL-EVENT-BEACON-LOSS Apr 28 20:47:25 ideapad2 wpa_supplicant[1161]: wlp3s0f3u4: CTRL-EVENT-DISCONNECTED bssid=... reason=4 locally_generated=1
Apr 28 20:47:34 ideapad2 wpa_supplicant[1161]: wlp3s0f3u4: CTRL-EVENT-BEACON-LOSS Apr 28 20:47:35 ideapad2 wpa_supplicant[1161]: wlp3s0f3u4: CTRL-EVENT-DISCONNECTED bssid=... reason=4 locally_generated=1
When the beacon loss happens, mac80211 makes rtw88 transmit a QOS NULL frame and asks to confirm the ACK status. Even though rtw88 confirms to mac80211 that the QOS NULL was transmitted successfully, the connection still dies. This is because rtw88 is handing the QOS NULL back to mac80211 with skb->data pointing to the headroom (the TX descriptor) instead of ieee80211_hdr.
Fix the disconnection by moving skb->data to the correct position before ieee80211_tx_status_irqsafe().
The problem was observed with RTL8811AU (TP-Link Archer T2U Nano) and the potential future rtw88_8821au driver. Also tested with RTL8811CU (Tenda U9).
--- drivers/net/wireless/realtek/rtw88/usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/realtek/rtw88/usb.c +2 -0
@@ -273,6 +273,8 @@ static void rtw_usb_write_port_tx_comple info =IEEE80211_SKB_CB (skb); tx_data =rtw_usb_get_tx_data (skb); +skb_pull (skb, rtwdev->chip->tx_pkt_desc_sz); +/* enqueue to wait for tx report */ if (info->flags &IEEE80211_TX_CTL_REQ_TX_STATUS ) {rtw_tx_report_enqueue (rtwdev, skb, tx_data->sn);
Greg Kroah-Hartman
maintainerPATCH 602/809 wifi: rtw88: usb: Further limit the TX aggregation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit d7dd13ea54af8496aca2762a758d817d6813e81c upstream.
Currently the number of frames sent to the chip in a single USB Request Block is limited only by the size of the TX buffer, which is 20 KiB. Testing reveals that as many as 13 frames get aggregated. This is more than what any of the chips would like to receive. RTL8822CU, RTL8822BU, and RTL8821CU want at most 3 frames, and RTL8723DU wants only 1 frame per URB.
RTL8723DU in particular reliably malfunctions during a speed test if it receives more than 1 frame per URB. All traffic seems to stop. Pinging the AP no longer works.
Fix this problem by limiting the number of frames sent to the chip in a single URB according to what each chip likes.
Also configure RTL8822CU, RTL8822BU, and RTL8821CU to expect 3 frames per URB.
RTL8703B may or may not be found in USB devices. Declare that it wants only 1 frame per URB, just in case.
Tested with RTL8723DU and RTL8811CU.
--- drivers/net/wireless/realtek/rtw88/mac.c | 9 +++++++++ drivers/net/wireless/realtek/rtw88/main.h | 2 ++ drivers/net/wireless/realtek/rtw88/reg.h | 1 + drivers/net/wireless/realtek/rtw88/rtw8703b.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8723d.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8821c.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8822b.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8822c.c | 1 + drivers/net/wireless/realtek/rtw88/usb.c | 4 +++- 9 files changed, 20 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/mac.c +9 -0
@@ -1201,6 +1201,15 @@ static int __priority_queue_cfg(struct rrtw_write16 (rtwdev,REG_FIFOPAGE_CTRL_2 +2 , fifo->rsvd_boundary);rtw_write16 (rtwdev,REG_BCNQ1_BDNY_V1 , fifo->rsvd_boundary);rtw_write32 (rtwdev,REG_RXFF_BNDY , chip->rxff_size -C2H_PKT_BUF -1 ); + +if (rtwdev->hci.type ==RTW_HCI_TYPE_USB ) { +rtw_write8_mask (rtwdev,REG_AUTO_LLT_V1 ,BIT_MASK_BLK_DESC_NUM , + chip->usb_tx_agg_desc_num); + +rtw_write8 (rtwdev,REG_AUTO_LLT_V1 +3 , chip->usb_tx_agg_desc_num); +rtw_write8_set (rtwdev,REG_TXDMA_OFFSET_CHK +1 ,BIT (1 )); + } +rtw_write8_set (rtwdev,REG_AUTO_LLT_V1 ,BIT_AUTO_INIT_LLT_V1 );if (!check_hw_ready (rtwdev,REG_AUTO_LLT_V1 ,BIT_AUTO_INIT_LLT_V1 ,0 ))
drivers/net/wireless/realtek/rtw88/main.h +2 -0
@@ -1197,6 +1197,8 @@ struct rtw_chip_info {u16 fw_fifo_addr[RTW_FW_FIFO_MAX ];const struct rtw_fwcd_segs *fwcd_segs; +u8 usb_tx_agg_desc_num; +u8 default_1ss_tx_path;bool path_div_supported;
drivers/net/wireless/realtek/rtw88/reg.h +1 -0
@@ -270,6 +270,7 @@#define BIT_MASK_BCN_HEAD_1_V1 0xfff#define REG_AUTO_LLT_V1 0x0208#define BIT_AUTO_INIT_LLT_V1 BIT(0) +#define BIT_MASK_BLK_DESC_NUM GENMASK(7, 4)#define REG_DWBCN0_CTRL 0x0208#define BIT_BCN_VALID BIT(16)#define REG_TXDMA_OFFSET_CHK 0x020C
drivers/net/wireless/realtek/rtw88/rtw8703b.c +1 -0
@@ -2013,6 +2013,7 @@ const struct rtw_chip_info rtw8703b_hw_s .tx_stbc = false, .max_power_index = 0x3f, .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, + .usb_tx_agg_desc_num = 1, /* Not sure if this chip has USB interface */ .path_div_supported = false, .ht_supported = true,
drivers/net/wireless/realtek/rtw88/rtw8723d.c +1 -0
@@ -2171,6 +2171,7 @@ const struct rtw_chip_info rtw8723d_hw_s .band = RTW_BAND_2G, .page_size = TX_PAGE_SIZE, .dig_min = 0x20, + .usb_tx_agg_desc_num = 1, .ht_supported = true, .vht_supported = false, .lps_deep_mode_supported = 0,
drivers/net/wireless/realtek/rtw88/rtw8821c.c +1 -0
@@ -2008,6 +2008,7 @@ const struct rtw_chip_info rtw8821c_hw_s .band = RTW_BAND_2G | RTW_BAND_5G, .page_size = TX_PAGE_SIZE, .dig_min = 0x1c, + .usb_tx_agg_desc_num = 3, .ht_supported = true, .vht_supported = true, .lps_deep_mode_supported = BIT(LPS_DEEP_MODE_LCLK),
drivers/net/wireless/realtek/rtw88/rtw8822b.c +1 -0
@@ -2548,6 +2548,7 @@ const struct rtw_chip_info rtw8822b_hw_s .band = RTW_BAND_2G | RTW_BAND_5G, .page_size = TX_PAGE_SIZE, .dig_min = 0x1c, + .usb_tx_agg_desc_num = 3, .ht_supported = true, .vht_supported = true, .lps_deep_mode_supported = BIT(LPS_DEEP_MODE_LCLK),
drivers/net/wireless/realtek/rtw88/rtw8822c.c +1 -0
@@ -5366,6 +5366,7 @@ const struct rtw_chip_info rtw8822c_hw_s .band = RTW_BAND_2G | RTW_BAND_5G, .page_size = TX_PAGE_SIZE, .dig_min = 0x20, + .usb_tx_agg_desc_num = 3, .default_1ss_tx_path = BB_PATH_A, .path_div_supported = true, .ht_supported = true,
drivers/net/wireless/realtek/rtw88/usb.c +3 -1
@@ -379,7 +379,9 @@ static bool rtw_usb_tx_agg_skb(struct rt skb_iter =skb_peek (list); -if (skb_iter && skb_iter->len + skb_head->len <=RTW_USB_MAX_XMITBUF_SZ ) +if (skb_iter && + skb_iter->len + skb_head->len <=RTW_USB_MAX_XMITBUF_SZ && + agg_num < rtwdev->chip->usb_tx_agg_desc_num)__skb_unlink (skb_iter, list);else skb_iter =NULL ;
Greg Kroah-Hartman
maintainerPATCH 603/809 cpufreq: qcom-nvmem: fix memory leaks in probe error paths
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
commit d01c84b97f19f1137211e90b0a910289a560019e upstream.
The code refactoring added new error paths between the np device node allocation and the call to of_node_put(), which leads to memory leaks if any of those errors occur.
Add the missing of_node_put() in the error paths that require it.
--- drivers/cpufreq/qcom-cpufreq-nvmem.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/cpufreq/qcom-cpufreq-nvmem.c +10 -3
@@ -480,23 +480,30 @@ static int qcom_cpufreq_probe(struct pla drv =devm_kzalloc (&pdev->dev,struct_size (drv, cpus,num_possible_cpus ()),GFP_KERNEL ); -if (!drv) +if (!drv) { +of_node_put (np);return -ENOMEM ; + } match = pdev->dev.platform_data; drv->data = match->data; -if (!drv->data) +if (!drv->data) { +of_node_put (np);return -ENODEV ; + }if (drv->data->get_version) { speedbin_nvmem =of_nvmem_cell_get (np,NULL ); -if (IS_ERR (speedbin_nvmem)) +if (IS_ERR (speedbin_nvmem)) { +of_node_put (np);return dev_err_probe (cpu_dev,PTR_ERR (speedbin_nvmem),"Could not get nvmem cell\n" ); + } ret = drv->data->get_version (cpu_dev, speedbin_nvmem, &pvs_name, drv);if (ret) { +of_node_put (np);nvmem_cell_put (speedbin_nvmem);return ret; }
Greg Kroah-Hartman
maintainerPATCH 604/809 drivers: soc: xilinx: check return status of get_api_version()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jay Buddhabhatti <[email protected]>
commit 9b003e14801cf85a8cebeddc87bc9fc77100fdce upstream.
Currently return status is not getting checked for get_api_version and because of that for x86 arch we are getting below smatch error.
CC drivers/soc/xilinx/zynqmp_power.odrivers/soc/xilinx/zynqmp_power.c: In function 'zynqmp_pm_probe':drivers/soc/xilinx/zynqmp_power.c:295:12: warning: 'pm_api_version' is used uninitialized [-Wuninitialized]
295 | if (pm_api_version < ZYNQMP_PM_VERSION)
| ^
CHECK drivers/soc/xilinx/zynqmp_power.cdrivers/soc/xilinx/zynqmp_power.c:295 zynqmp_pm_probe() error:
uninitialized symbol 'pm_api_version'.
So, check return status of pm_get_api_version and return error in case of failure to avoid checking uninitialized pm_api_version variable.
--- drivers/soc/xilinx/zynqmp_power.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soc/xilinx/zynqmp_power.c +3 -1
@@ -190,7 +190,9 @@ static int zynqmp_pm_probe(struct platfou32 pm_api_version;struct mbox_client *client; -zynqmp_pm_get_api_version (&pm_api_version); + ret =zynqmp_pm_get_api_version (&pm_api_version); +if (ret) +return ret;/* Check PM API version number */ if (pm_api_version <ZYNQMP_PM_VERSION )
Greg Kroah-Hartman
maintainerPATCH 605/809 leds: ss4200: Convert PCIBIOS_* return codes to errnos
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit ce068e83976140badb19c7f1307926b4b562fac4 upstream.
ich7_lpc_probe() uses pci_read_config_dword() that returns PCIBIOS_* codes. The error handling code assumes incorrectly it's a normal errno and checks for < 0. The return code is returned from the probe function as is but probe functions should return normal errnos.
Remove < 0 from the check and convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.
--- drivers/leds/leds-ss4200.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/leds/leds-ss4200.c +5 -2
@@ -356,8 +356,10 @@ static int ich7_lpc_probe(struct pci_dev nas_gpio_pci_dev = dev; status =pci_read_config_dword (dev,PMBASE , &g_pm_io_base); -if (status) +if (status) { + status =pcibios_err_to_errno (status); goto out; + } g_pm_io_base &=0x00000ff80 ; status =pci_read_config_dword (dev,GPIO_CTRL , &gc);
@@ -369,8 +371,9 @@ static int ich7_lpc_probe(struct pci_dev } status =pci_read_config_dword (dev,GPIO_BASE , &nas_gpio_io_base); -if (0 > status) { +if (status) {dev_info (&dev->dev,"Unable to read GPIOBASE.\n" ); + status =pcibios_err_to_errno (status); goto out; }dev_dbg (&dev->dev,": GPIOBASE = 0x%08x\n" , nas_gpio_io_base);
Greg Kroah-Hartman
maintainerPATCH 606/809 md/md-bitmap: fix writing non bitmap pages
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ofir Gal <[email protected]>
commit ab99a87542f194f28e2364a42afbf9fb48b1c724 upstream.
__write_sb_page() rounds up the io size to the optimal io size if it doesn't exceed the data offset, but it doesn't check the final size exceeds the bitmap length.
For example:
page count - 1 page size - 4K data offset - 1M
optimal io size - 256K
The final io size would be 256K (64 pages) but md_bitmap_storage_alloc() allocated 1 page, the IO would write 1 valid page and 63 pages that happens to be allocated afterwards. This leaks memory to the raid device superblock.
This issue caused a data transfer failure in nvme-tcp. The network drivers checks the first page of an IO with sendpage_ok(), it returns true if the page isn't a slabpage and refcount >= 1. If the page !sendpage_ok() the network driver disables MSG_SPLICE_PAGES.
As of now the network layer assumes all the pages of the IO are sendpage_ok() when MSG_SPLICE_PAGES is on.
The bitmap pages aren't slab pages, the first page of the IO is sendpage_ok(), but the additional pages that happens to be allocated after the bitmap pages might be !sendpage_ok(). That cause skb_splice_from_iter() to stop the data transfer, in the case below it hangs 'mdadm --create'.
The bug is reproducible, in order to reproduce we need nvme-over-tcp controllers with optimal IO size bigger than PAGE_SIZE. Creating a raid with bitmap over those devices reproduces the bug.
In order to simulate large optimal IO size you can use dm-stripe with a single device.
Script to reproduce the issue on top of brd devices using dm-stripe is attached below (will be added to blktest).
I have added some logs to test the theory:
...
md: created bitmap (1 pages) for device md127__write_sb_page before md_super_write offset: 16, size: 262144. pfn: 0x53ee === __write_sb_page before md_super_write. logging pages ===
pfn: 0x53ee, slab: 0 <-- the only page that allocated for the bitmap
pfn: 0x53ef, slab: 1
pfn: 0x53f0, slab: 0
pfn: 0x53f1, slab: 0
pfn: 0x53f2, slab: 0
pfn: 0x53f3, slab: 1
...nvme_tcp: sendpage_ok - pfn: 0x53ee, len: 262144, offset: 0
skbuff: before sendpage_ok() - pfn: 0x53ee
skbuff: before sendpage_ok() - pfn: 0x53ef
WARNING at net/core/skbuff.c:6848 skb_splice_from_iter+0x142/0x450
skbuff: !sendpage_ok - pfn: 0x53ef. is_slab: 1, page_count: 1
...
--- drivers/md/md-bitmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/md-bitmap.c +3 -3
@@ -227,6 +227,8 @@ static int __write_sb_page(struct md_rdestruct block_device *bdev;struct mddev *mddev = bitmap->mddev;struct bitmap_storage *store = &bitmap->storage; +unsigned int bitmap_limit = (bitmap->storage.file_pages - pg_index) << +PAGE_SHIFT ;loff_t sboff, offset = mddev->bitmap_info.offset;sector_t ps = pg_index *PAGE_SIZE /SECTOR_SIZE ;unsigned int size =PAGE_SIZE ;
@@ -269,11 +271,9 @@ static int __write_sb_page(struct md_rdeif (size ==0 )/* bitmap runs in to data */ return -EINVAL ; - }else { -/* DATA METADATA BITMAP - no problems */ } -md_super_write (mddev, rdev, sboff + ps, (int ) size, page); +md_super_write (mddev, rdev, sboff + ps, (int )min (size, bitmap_limit), page);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 607/809 leds: triggers: Flush pending brightness before activating trigger
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit ab477b766edd3bfb6321a6e3df4c790612613fae upstream.
The race fixed in timer_trig_activate() between a blocking set_brightness() call and trigger->activate() can affect any trigger. So move the call to flush_work() into led_trigger_set() where it can avoid the race for all triggers.
--- drivers/leds/led-triggers.c | 6 ++++++ drivers/leds/trigger/ledtrig-timer.c | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/leds/led-triggers.c +6 -0
@@ -194,6 +194,12 @@ int led_trigger_set(struct led_classdevspin_unlock (&trig->leddev_list_lock); led_cdev->trigger = trig; +/* +* If "set brightness to 0" is pending in workqueue, +* we don't want that to be reordered after ->activate() +*/ +flush_work (&led_cdev->set_brightness_work); + ret =0 ;if (trig->activate) ret = trig->activate (led_cdev);
drivers/leds/trigger/ledtrig-timer.c +0 -5
@@ -110,11 +110,6 @@ static int timer_trig_activate(struct le led_cdev->flags &= ~LED_INIT_DEFAULT_TRIGGER ; } -/* -* If "set brightness to 0" is pending in workqueue, we don't -* want that to be reordered after blink_set() -*/ -flush_work (&led_cdev->set_brightness_work);led_blink_set (led_cdev, &led_cdev->blink_delay_on, &led_cdev->blink_delay_off);
Greg Kroah-Hartman
maintainerPATCH 608/809 leds: mt6360: Fix memory leak in mt6360_init_isnk_properties()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
commit e41d574b359ccd8d99be65c6f11502efa2b83136 upstream.
The fwnode_for_each_child_node() loop requires manual intervention to decrement the child refcount in case of an early return.
Add the missing calls to fwnode_handle_put(child) to avoid memory leaks in the error paths.
--- drivers/leds/flash/leds-mt6360.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/leds/flash/leds-mt6360.c +4 -1
@@ -643,14 +643,17 @@ static int mt6360_init_isnk_properties(s ret =fwnode_property_read_u32 (child,"reg" , ®);if (ret || reg >MT6360_LED_ISNK3 || - priv->leds_active &BIT (reg)) + priv->leds_active &BIT (reg)) { +fwnode_handle_put (child);return -EINVAL ; + } ret =fwnode_property_read_u32 (child,"color" , &color);if (ret) {dev_err (priv->dev,"led %d, no color specified\n" , led->led_no); +fwnode_handle_put (child);return ret; }
Greg Kroah-Hartman
maintainerPATCH 609/809 media: ivsc: csi: add separate lock for v4l2 control handler
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentong Wu <[email protected]>
commit c6be6471004e0e4d10d0514146d8c41550823d63 upstream.
There're possibilities that privacy status change notification happens in the middle of the ongoing mei command which already takes the command lock, but v4l2_ctrl_s_ctrl() would also need the same lock prior to this patch, so this may results in circular locking problem. This patch adds one dedicated lock for v4l2 control handler to avoid described issue.
--- drivers/media/pci/intel/ivsc/mei_csi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/pci/intel/ivsc/mei_csi.c +7 -1
@@ -126,6 +126,8 @@ struct mei_csi {struct v4l2_ctrl_handler ctrl_handler;struct v4l2_ctrl *freq_ctrl;struct v4l2_ctrl *privacy_ctrl; +/* lock for v4l2 controls */ +struct mutex ctrl_lock;unsigned int remote_pad;/* start streaming or not */ int streaming;
@@ -559,11 +561,13 @@ static int mei_csi_init_controls(structu32 max;int ret; +mutex_init (&csi->ctrl_lock); + ret =v4l2_ctrl_handler_init (&csi->ctrl_handler,2 );if (ret)return ret; - csi->ctrl_handler.lock = &csi->lock; + csi->ctrl_handler.lock = &csi->ctrl_lock; max =ARRAY_SIZE (link_freq_menu_items) -1 ; csi->freq_ctrl = v4l2_ctrl_new_int_menu(&csi->ctrl_handler,
@@ -755,6 +759,7 @@ err_entity: err_ctrl_handler:v4l2_ctrl_handler_free (&csi->ctrl_handler); +mutex_destroy (&csi->ctrl_lock);v4l2_async_nf_unregister (&csi->notifier);v4l2_async_nf_cleanup (&csi->notifier);
@@ -774,6 +779,7 @@ static void mei_csi_remove(struct mei_clv4l2_async_nf_unregister (&csi->notifier);v4l2_async_nf_cleanup (&csi->notifier);v4l2_ctrl_handler_free (&csi->ctrl_handler); +mutex_destroy (&csi->ctrl_lock);v4l2_async_unregister_subdev (&csi->subdev);v4l2_subdev_cleanup (&csi->subdev);media_entity_cleanup (&csi->subdev.entity);
Greg Kroah-Hartman
maintainerPATCH 610/809 media: i2c: alvium: Move V4L2_CID_GAIN to V4L2_CID_ANALOG_GAIN
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tommaso Merciai <[email protected]>
commit a50a2a3242f35dd551d89a6bad17255a410ba955 upstream.
Into alvium cameras REG_BCRM_GAIN_RW control the analog gain. Let's use the right V4L2_CID_ANALOGUE_GAIN ctrl.
--- drivers/media/i2c/alvium-csi2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/i2c/alvium-csi2.c +3 -3
@@ -1962,7 +1962,7 @@ static int alvium_g_volatile_ctrl(structint val;switch (ctrl->id) { -case V4L2_CID_GAIN : +case V4L2_CID_ANALOGUE_GAIN : val =alvium_get_gain (alvium);if (val <0 )return val;
@@ -1994,7 +1994,7 @@ static int alvium_s_ctrl(struct v4l2_ctrreturn 0 ;switch (ctrl->id) { -case V4L2_CID_GAIN : +case V4L2_CID_ANALOGUE_GAIN : ret =alvium_set_ctrl_gain (alvium, ctrl->val);break ;case V4L2_CID_AUTOGAIN :
@@ -2123,7 +2123,7 @@ static int alvium_ctrl_init(struct alviuif (alvium->avail_ft.gain) { ctrls->gain = v4l2_ctrl_new_std(hdl, ops, - V4L2_CID_GAIN, + V4L2_CID_ANALOGUE_GAIN, alvium->min_gain, alvium->max_gain, alvium->inc_gain,
Greg Kroah-Hartman
maintainerPATCH 611/809 media: imx-pxp: Fix ERR_PTR dereference in pxp_probe()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harshit Mogalapalli <[email protected]>
commit 57e9ce68ae98551da9c161aaab12b41fe8601856 upstream.
devm_regmap_init_mmio() can fail, add a check and bail out in case of error.
--- drivers/media/platform/nxp/imx-pxp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/nxp/imx-pxp.c +3 -0
@@ -1805,6 +1805,9 @@ static int pxp_probe(struct platform_devreturn PTR_ERR (mmio); dev->regmap =devm_regmap_init_mmio (&pdev->dev, mmio, &pxp_regmap_config); +if (IS_ERR (dev->regmap)) +return dev_err_probe (&pdev->dev,PTR_ERR (dev->regmap), +"Failed to init regmap\n" ); irq =platform_get_irq (pdev,0 );if (irq <0 )
Greg Kroah-Hartman
maintainerPATCH 612/809 jbd2: make jbd2_journal_get_max_txn_bufs() internal
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 4aa99c71e42ad60178c1154ec24e3df9c684fb67 upstream.
There's no reason to have jbd2_journal_get_max_txn_bufs() public function. Currently all users are internal and can use journal->j_max_transaction_buffers instead. This saves some unnecessary recomputations of the limit as a bonus which becomes important as this function gets more complex in the following patch.
--- fs/jbd2/commit.c | 2 +- fs/jbd2/journal.c | 5 +++++ include/linux/jbd2.h | 5 ----- 3 files changed, 6 insertions(+), 6 deletions(-)
fs/jbd2/commit.c +1 -1
@@ -766,7 +766,7 @@ start_journal_io:if (first_block < journal->j_tail) freed += journal->j_last - journal->j_first;/* Update tail only if we free significant amount of space */ -if (freed <jbd2_journal_get_max_txn_bufs (journal)) +if (freed < journal->j_max_transaction_buffers) update_tail =0 ; }J_ASSERT (commit_transaction->t_state ==T_COMMIT );
fs/jbd2/journal.c +5 -0
@@ -1698,6 +1698,11 @@ journal_t *jbd2_journal_init_inode(strucreturn journal; } +static int jbd2_journal_get_max_txn_bufs (journal_t *journal) +{ +return (journal->j_total_len - journal->j_fc_wbufsize) /4 ; +} +/* * Given a journal_t structure, initialise the various fields for * startup of a new journaling session. We use this both when creating
include/linux/jbd2.h +0 -5
@@ -1660,11 +1660,6 @@ int jbd2_wait_inode_data(journal_t *jourint jbd2_fc_wait_bufs (journal_t *journal,int num_blks);int jbd2_fc_release_bufs (journal_t *journal); -static inline int jbd2_journal_get_max_txn_bufs (journal_t *journal) -{ -return (journal->j_total_len - journal->j_fc_wbufsize) /4 ; -} -/* * is_journal_abort *
Greg Kroah-Hartman
maintainerPATCH 613/809 jbd2: precompute number of transaction descriptor blocks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit e3a00a23781c1f2fcda98a7aecaac515558e7a35 upstream.
Instead of computing the number of descriptor blocks a transaction can have each time we need it (which is currently when starting each transaction but will become more frequent later) precompute the number once during journal initialization together with maximum transaction size. We perform the precomputation whenever journal feature set is updated similarly as for computation of journal->j_revoke_records_per_block.
--- fs/jbd2/journal.c | 61 +++++++++++++++++++++++++++++++++++++------------- fs/jbd2/transaction.c | 24 ------------------- include/linux/jbd2.h | 7 +++++ 3 files changed, 54 insertions(+), 38 deletions(-)
fs/jbd2/journal.c +46 -15
@@ -1451,6 +1451,48 @@ static int journal_revoke_records_per_blreturn space / record_size; } +static int jbd2_journal_get_max_txn_bufs (journal_t *journal) +{ +return (journal->j_total_len - journal->j_fc_wbufsize) /4 ; +} + +/* +* Base amount of descriptor blocks we reserve for each transaction. +*/ +static int jbd2_descriptor_blocks_per_trans (journal_t *journal) +{ +int tag_space = journal->j_blocksize -sizeof (journal_header_t); +int tags_per_block; + +/* Subtract UUID */ + tag_space -=16 ; +if (jbd2_journal_has_csum_v2or3 (journal)) + tag_space -=sizeof (struct jbd2_journal_block_tail ); +/* Commit code leaves a slack space of 16 bytes at the end of block */ + tags_per_block = (tag_space -16 ) /journal_tag_bytes (journal); +/* +* Revoke descriptors are accounted separately so we need to reserve +* space for commit block and normal transaction descriptor blocks. +*/ +return 1 +DIV_ROUND_UP (jbd2_journal_get_max_txn_bufs (journal), + tags_per_block); +} + +/* +* Initialize number of blocks each transaction reserves for its bookkeeping +* and maximum number of blocks a transaction can use. This needs to be called +* after the journal size and the fastcommit area size are initialized. +*/ +static void jbd2_journal_init_transaction_limits (journal_t *journal) +{ + journal->j_revoke_records_per_block = +journal_revoke_records_per_block (journal); + journal->j_transaction_overhead_buffers = +jbd2_descriptor_blocks_per_trans (journal); + journal->j_max_transaction_buffers = +jbd2_journal_get_max_txn_bufs (journal); +} +/* * Load the on-disk journal superblock and read the key fields into the * journal_t.
@@ -1492,8 +1534,8 @@ static int journal_load_superblock(journif (jbd2_journal_has_csum_v2or3 (journal)) journal->j_csum_seed =jbd2_chksum (journal, ~0 , sb->s_uuid,sizeof (sb->s_uuid)); - journal->j_revoke_records_per_block = -journal_revoke_records_per_block (journal); +/* After journal features are set, we can compute transaction limits */ +jbd2_journal_init_transaction_limits (journal);if (jbd2_has_feature_fast_commit (journal)) { journal->j_fc_last =be32_to_cpu (sb->s_maxlen);
@@ -1698,11 +1740,6 @@ journal_t *jbd2_journal_init_inode(strucreturn journal; } -static int jbd2_journal_get_max_txn_bufs (journal_t *journal) -{ -return (journal->j_total_len - journal->j_fc_wbufsize) /4 ; -} -/* * Given a journal_t structure, initialise the various fields for * startup of a new journaling session. We use this both when creating
@@ -1748,8 +1785,6 @@ static int journal_reset(journal_t *jour journal->j_commit_sequence = journal->j_transaction_sequence -1 ; journal->j_commit_request = journal->j_commit_sequence; - journal->j_max_transaction_buffers =jbd2_journal_get_max_txn_bufs (journal); -/* * Now that journal recovery is done, turn fast commits off here. This * way, if fast commit was enabled before the crash but if now FS has
@@ -2290,8 +2325,6 @@ jbd2_journal_initialize_fast_commit(jour journal->j_fc_first = journal->j_last +1 ; journal->j_fc_off =0 ; journal->j_free = journal->j_last - journal->j_first; - journal->j_max_transaction_buffers = -jbd2_journal_get_max_txn_bufs (journal);return 0 ; }
@@ -2379,8 +2412,7 @@ int jbd2_journal_set_features(journal_t sb->s_feature_ro_compat |=cpu_to_be32 (ro); sb->s_feature_incompat |=cpu_to_be32 (incompat);unlock_buffer (journal->j_sb_buffer); - journal->j_revoke_records_per_block = -journal_revoke_records_per_block (journal); +jbd2_journal_init_transaction_limits (journal);return 1 ;#undef COMPAT_FEATURE_ON
@@ -2411,8 +2443,7 @@ void jbd2_journal_clear_features(journal sb->s_feature_compat &= ~cpu_to_be32 (compat); sb->s_feature_ro_compat &= ~cpu_to_be32 (ro); sb->s_feature_incompat &= ~cpu_to_be32 (incompat); - journal->j_revoke_records_per_block = -journal_revoke_records_per_block (journal); +jbd2_journal_init_transaction_limits (journal); }EXPORT_SYMBOL (jbd2_journal_clear_features);
fs/jbd2/transaction.c +1 -23
@@ -63,28 +63,6 @@ void jbd2_journal_free_transaction(trans }/* -* Base amount of descriptor blocks we reserve for each transaction. -*/ -static int jbd2_descriptor_blocks_per_trans (journal_t *journal) -{ -int tag_space = journal->j_blocksize -sizeof (journal_header_t); -int tags_per_block; - -/* Subtract UUID */ - tag_space -=16 ; -if (jbd2_journal_has_csum_v2or3 (journal)) - tag_space -=sizeof (struct jbd2_journal_block_tail ); -/* Commit code leaves a slack space of 16 bytes at the end of block */ - tags_per_block = (tag_space -16 ) /journal_tag_bytes (journal); -/* -* Revoke descriptors are accounted separately so we need to reserve -* space for commit block and normal transaction descriptor blocks. -*/ -return 1 +DIV_ROUND_UP (journal->j_max_transaction_buffers, - tags_per_block); -} - -/* * jbd2_get_transaction: obtain a new transaction_t object. * * Simply initialise a new transaction. Initialize it in
@@ -109,7 +87,7 @@ static void jbd2_get_transaction(journal transaction->t_expires = jiffies + journal->j_commit_interval;atomic_set (&transaction->t_updates,0 );atomic_set (&transaction->t_outstanding_credits, -jbd2_descriptor_blocks_per_trans (journal) + + journal->j_transaction_overhead_buffers +atomic_read (&journal->j_reserved_credits));atomic_set (&transaction->t_outstanding_revokes,0 );atomic_set (&transaction->t_handle_count,0 );
include/linux/jbd2.h +7 -0
@@ -1086,6 +1086,13 @@ struct journal_sint j_revoke_records_per_block;/** +* @j_transaction_overhead: +* +* Number of blocks each transaction needs for its own bookkeeping +*/ +int j_transaction_overhead_buffers; + +/** * @j_commit_interval: * * What is the maximum transaction lifetime before we begin a commit?
Greg Kroah-Hartman
maintainerPATCH 614/809 jbd2: avoid infinite transaction commit loop
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 27ba5b67312a944576addc4df44ac3b709aabede upstream.
Commit 9f356e5a4f12 ("jbd2: Account descriptor blocks into t_outstanding_credits") started to account descriptor blocks into transactions outstanding credits. However it didn't appropriately decrease the maximum amount of credits available to userspace. Thus if the filesystem requests a transaction smaller than j_max_transaction_buffers but large enough that when descriptor blocks are added the size exceeds j_max_transaction_buffers, we confuse add_transaction_credits() into thinking previous handles have grown the transaction too much and enter infinite journal commit loop in start_this_handle() -> add_transaction_credits() trying to create transaction with enough credits available.
Fix the problem by properly accounting for transaction space reserved for descriptor blocks when verifying requested transaction handle size.
--- fs/jbd2/transaction.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
fs/jbd2/transaction.c +14 -7
@@ -191,6 +191,13 @@ static void sub_reserved_credits(journalwake_up (&journal->j_wait_reserved); } +/* Maximum number of blocks for user transaction payload */ +static int jbd2_max_user_trans_buffers (journal_t *journal) +{ +return journal->j_max_transaction_buffers - + journal->j_transaction_overhead_buffers; +} +/* * Wait until we can add credits for handle to the running transaction. Called * with j_state_lock held for reading. Returns 0 if handle joined the running
@@ -240,12 +247,12 @@ __must_hold(&journal->j_state_lock)* big to fit this handle? Wait until reserved credits are freed. */ if (atomic_read (&journal->j_reserved_credits) + total > - journal->j_max_transaction_buffers) { +jbd2_max_user_trans_buffers (journal)) {read_unlock (&journal->j_state_lock);jbd2_might_wait_for_commit (journal);wait_event (journal->j_wait_reserved,atomic_read (&journal->j_reserved_credits) + total <= - journal->j_max_transaction_buffers); +jbd2_max_user_trans_buffers (journal));__acquire (&journal->j_state_lock);/* fake out sparse */ return 1 ; }
@@ -285,14 +292,14 @@ __must_hold(&journal->j_state_lock) needed =atomic_add_return (rsv_blocks, &journal->j_reserved_credits);/* We allow at most half of a transaction to be reserved */ -if (needed > journal->j_max_transaction_buffers /2 ) { +if (needed >jbd2_max_user_trans_buffers (journal) /2 ) {sub_reserved_credits (journal, rsv_blocks);atomic_sub (total, &t->t_outstanding_credits);read_unlock (&journal->j_state_lock);jbd2_might_wait_for_commit (journal);wait_event (journal->j_wait_reserved,atomic_read (&journal->j_reserved_credits) + rsv_blocks - <= journal->j_max_transaction_buffers /2 ); + <=jbd2_max_user_trans_buffers (journal) /2 );__acquire (&journal->j_state_lock);/* fake out sparse */ return 1 ; }
@@ -322,12 +329,12 @@ static int start_this_handle(journal_t ** size and limit the number of total credits to not exceed maximum * transaction size per operation. */ -if ((rsv_blocks > journal->j_max_transaction_buffers /2 ) || - (rsv_blocks + blocks > journal->j_max_transaction_buffers)) { +if (rsv_blocks >jbd2_max_user_trans_buffers (journal) /2 || + rsv_blocks + blocks >jbd2_max_user_trans_buffers (journal)) {printk (KERN_ERR "JBD2: %s wants too many credits " "credits:%d rsv_credits:%d max:%d\n" , current->comm, blocks, rsv_blocks, - journal->j_max_transaction_buffers); +jbd2_max_user_trans_buffers (journal));WARN_ON (1 );return -ENOSPC ; }
Greg Kroah-Hartman
maintainerPATCH 615/809 media: uvcvideo: Fix integer overflow calculating timestamp
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit 8676a5e796fa18f55897ca36a94b2adf7f73ebd1 upstream.
The function uvc_video_clock_update() supports a single SOF overflow. Or in other words, the maximum difference between the first ant the last timestamp can be 4096 ticks or 4.096 seconds.
This results in a maximum value for y2 of: 0x12FBECA00, that overflows 32bits.
y2 = (u32)ktime_to_ns(ktime_sub(last->host_time, first->host_time)) + y1;
Extend the size of y2 to u64 to support all its values.
Without this patch:
# yavta -s 1920x1080 -f YUYV -t 1/5 -c /dev/video0 Device /dev/v4l/by-id/usb-Shine-Optics_Integrated_Camera_0001-video-index0 opened. Device `Integrated Camera: Integrated C' on `usb-0000:00:14.0-6' (driver 'uvcvideo') supports video, capture, without mplanes. Video format set: YUYV (56595559) 1920x1080 (stride 3840) field none buffer size 4147200 Video format: YUYV (56595559) 1920x1080 (stride 3840) field none buffer size 4147200 Current frame rate: 1/5 Setting frame rate to: 1/5 Frame rate set: 1/5 8 buffers requested. length: 4147200 offset: 0 timestamp type/source: mono/SoE Buffer 0/0 mapped at address 0x7947ea94c000. length: 4147200 offset: 4149248 timestamp type/source: mono/SoE Buffer 1/0 mapped at address 0x7947ea557000. length: 4147200 offset: 8298496 timestamp type/source: mono/SoE Buffer 2/0 mapped at address 0x7947ea162000. length: 4147200 offset: 12447744 timestamp type/source: mono/SoE Buffer 3/0 mapped at address 0x7947e9d6d000. length: 4147200 offset: 16596992 timestamp type/source: mono/SoE Buffer 4/0 mapped at address 0x7947e9978000. length: 4147200 offset: 20746240 timestamp type/source: mono/SoE Buffer 5/0 mapped at address 0x7947e9583000. length: 4147200 offset: 24895488 timestamp type/source: mono/SoE Buffer 6/0 mapped at address 0x7947e918e000. length: 4147200 offset: 29044736 timestamp type/source: mono/SoE Buffer 7/0 mapped at address 0x7947e8d99000. 0 (0) [-] none 0 4147200 B 507.554210 508.874282 242.836 fps ts mono/SoE 1 (1) [-] none 2 4147200 B 508.886298 509.074289 0.751 fps ts mono/SoE 2 (2) [-] none 3 4147200 B 509.076362 509.274307 5.261 fps ts mono/SoE 3 (3) [-] none 4 4147200 B 509.276371 509.474336 5.000 fps ts mono/SoE 4 (4) [-] none 5 4147200 B 509.476394 509.674394 4.999 fps ts mono/SoE 5 (5) [-] none 6 4147200 B 509.676506 509.874345 4.997 fps ts mono/SoE 6 (6) [-] none 7 4147200 B 509.876430 510.074370 5.002 fps ts mono/SoE 7 (7) [-] none 8 4147200 B 510.076434 510.274365 5.000 fps ts mono/SoE 8 (0) [-] none 9 4147200 B 510.276421 510.474333 5.000 fps ts mono/SoE 9 (1) [-] none 10 4147200 B 510.476391 510.674429 5.001 fps ts mono/SoE 10 (2) [-] none 11 4147200 B 510.676434 510.874283 4.999 fps ts mono/SoE 11 (3) [-] none 12 4147200 B 510.886264 511.074349 4.766 fps ts mono/SoE 12 (4) [-] none 13 4147200 B 511.070577 511.274304 5.426 fps ts mono/SoE 13 (5) [-] none 14 4147200 B 511.286249 511.474301 4.637 fps ts mono/SoE 14 (6) [-] none 15 4147200 B 511.470542 511.674251 5.426 fps ts mono/SoE 15 (7) [-] none 16 4147200 B 511.672651 511.874337 4.948 fps ts mono/SoE 16 (0) [-] none 17 4147200 B 511.873988 512.074462 4.967 fps ts mono/SoE 17 (1) [-] none 18 4147200 B 512.075982 512.278296 4.951 fps ts mono/SoE 18 (2) [-] none 19 4147200 B 512.282631 512.482423 4.839 fps ts mono/SoE 19 (3) [-] none 20 4147200 B 518.986637 512.686333 0.149 fps ts mono/SoE 20 (4) [-] none 21 4147200 B 518.342709 512.886386 -1.553 fps ts mono/SoE 21 (5) [-] none 22 4147200 B 517.909812 513.090360 -2.310 fps ts mono/SoE 22 (6) [-] none 23 4147200 B 517.590775 513.294454 -3.134 fps ts mono/SoE 23 (7) [-] none 24 4147200 B 513.298465 513.494335 -0.233 fps ts mono/SoE 24 (0) [-] none 25 4147200 B 513.510273 513.698375 4.721 fps ts mono/SoE 25 (1) [-] none 26 4147200 B 513.698904 513.902327 5.301 fps ts mono/SoE 26 (2) [-] none 27 4147200 B 513.895971 514.102348 5.074 fps ts mono/SoE 27 (3) [-] none 28 4147200 B 514.099091 514.306337 4.923 fps ts mono/SoE 28 (4) [-] none 29 4147200 B 514.310348 514.510567 4.734 fps ts mono/SoE 29 (5) [-] none 30 4147200 B 514.509295 514.710367 5.026 fps ts mono/SoE 30 (6) [-] none 31 4147200 B 521.532513 514.914398 0.142 fps ts mono/SoE 31 (7) [-] none 32 4147200 B 520.885277 515.118385 -1.545 fps ts mono/SoE 32 (0) [-] none 33 4147200 B 520.411140 515.318336 -2.109 fps ts mono/SoE 33 (1) [-] none 34 4147200 B 515.325425 515.522278 -0.197 fps ts mono/SoE 34 (2) [-] none 35 4147200 B 515.538276 515.726423 4.698 fps ts mono/SoE 35 (3) [-] none 36 4147200 B 515.720767 515.930373 5.480 fps ts mono/SoE
--- drivers/media/usb/uvc/uvc_video.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/usb/uvc/uvc_video.c +5 -5
@@ -720,11 +720,11 @@ void uvc_video_clock_update(struct uvc_sunsigned long flags;u64 timestamp;u32 delta_stc; -u32 y1, y2; +u32 y1;u32 x1, x2;u32 mean;u32 sof; -u64 y; +u64 y, y2;if (!uvc_hw_timestamps_param)return ;
@@ -764,7 +764,7 @@ void uvc_video_clock_update(struct uvc_s sof = y; uvc_dbg(stream->dev, CLOCK, - "%s: PTS %u y %llu.%06llu SOF %u.%06llu (x1 %u x2 %u y1 %u y2 %u SOF offset %u)\n", + "%s: PTS %u y %llu.%06llu SOF %u.%06llu (x1 %u x2 %u y1 %u y2 %llu SOF offset %u)\n", stream->dev->name, buf->pts, y >> 16, div_u64((y & 0xffff) * 1000000, 65536), sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536),
@@ -779,7 +779,7 @@ void uvc_video_clock_update(struct uvc_s goto done; y1 =NSEC_PER_SEC ; - y2 = (u32 )ktime_to_ns (ktime_sub (last->host_time, first->host_time)) + y1; + y2 =ktime_to_ns (ktime_sub (last->host_time, first->host_time)) + y1;/* * Interpolated and host SOF timestamps can wrap around at slightly
@@ -800,7 +800,7 @@ void uvc_video_clock_update(struct uvc_s timestamp =ktime_to_ns (first->host_time) + y - y1; uvc_dbg(stream->dev, CLOCK, - "%s: SOF %u.%06llu y %llu ts %llu buf ts %llu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %u)\n", + "%s: SOF %u.%06llu y %llu ts %llu buf ts %llu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %llu)\n", stream->dev->name, sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536), y, timestamp, vbuf->vb2_buf.timestamp,
Greg Kroah-Hartman
maintainerPATCH 616/809 media: ivsc: csi: dont count privacy on as error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentong Wu <[email protected]>
commit a813f168336ec4ef725b836e598cd9dc14f76dd7 upstream.
Prior to the ongoing command privacy is on, it would return -1 to indicate the current privacy status, and the ongoing command would be well executed by firmware as well, so this is not error. This patch changes its behavior to notify privacy on directly by V4L2 privacy control instead of reporting error.
--- drivers/media/pci/intel/ivsc/mei_csi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/pci/intel/ivsc/mei_csi.c +5 -1
@@ -192,7 +192,11 @@ static int mei_csi_send(struct mei_csi */* command response status */ ret = csi->cmd_response.status; -if (ret) { +if (ret ==-1 ) { +/* notify privacy on instead of reporting error */ + ret =0 ; +v4l2_ctrl_s_ctrl (csi->privacy_ctrl,1 ); + }else if (ret) { ret = -EINVAL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 617/809 remoteproc: mediatek: Increase MT8188/MT8195 SCP core0 DRAM size
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Chen <[email protected]>
commit 19cb6058620620e68f1a9aed99393be5c3629db4 upstream.
The current DRAM size is insufficient for the HEVC feature, which requires more memory for proper functionality. This change ensures the feature has the necessary resources.
--- drivers/remoteproc/mtk_scp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/remoteproc/mtk_scp.c +7 -2
@@ -1388,7 +1388,7 @@ static const struct mtk_scp_sizes_data d };static const struct mtk_scp_sizes_data mt8188_scp_sizes = { - .max_dram_size =0x500000 , + .max_dram_size =0x800000 , .ipi_share_buffer_size =600 , };
@@ -1397,6 +1397,11 @@ static const struct mtk_scp_sizes_data m .ipi_share_buffer_size = 600, }; +static const struct mtk_scp_sizes_data mt8195_scp_sizes = { + .max_dram_size =0x800000 , + .ipi_share_buffer_size =288 , +}; +static const struct mtk_scp_of_data mt8183_of_data = { .scp_clk_get = mt8183_scp_clk_get, .scp_before_load = mt8183_scp_before_load,
@@ -1474,7 +1479,7 @@ static const struct mtk_scp_of_data mt81 .scp_da_to_va = mt8192_scp_da_to_va, .host_to_scp_reg = MT8192_GIPC_IN_SET, .host_to_scp_int_bit = MT8192_HOST_IPC_INT_BIT, - .scp_sizes = &default_scp_sizes, + .scp_sizes = &mt8195_scp_sizes, };static const struct mtk_scp_of_data mt8195_of_data_c1 = {
Greg Kroah-Hartman
maintainerPATCH 618/809 KVM: PPC: Book3S HV nestedv2: Fix doorbell emulation
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <[email protected]>
commit 54ec2bd9e0173b75daf84675d07c56584f96564b upstream.
Doorbell emulation is broken for KVM on PAPR guests as support for DPDES was not added in the initial patch series. Due to this, a KVM on PAPR guest with SMT > 1 cannot be booted with the XICS interrupt controller as doorbells are setup in the initial probe path when using XICS (pSeries_smp_probe()).
Command to replicate the above bug:
qemu-system-ppc64 \ -drive file=rhel.qcow2,format=qcow2 \ -m 20G \ -smp 8,cores=1,threads=8 \ -cpu host \ -nographic \ -machine pseries,ic-mode=xics -accel kvm
Add doorbell state handling support in the host KVM code to fix doorbell emulation.
--- arch/powerpc/kvm/book3s_hv.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/kvm/book3s_hv.c +5 -0
@@ -4116,6 +4116,11 @@ static int kvmhv_vcpu_entry_nestedv2(strint trap;long rc; +if (vcpu->arch.doorbell_request) { + vcpu->arch.doorbell_request =0 ; +kvmppc_set_dpdes (vcpu,1 ); + } + io = &vcpu->arch.nestedv2_io; msr =mfmsr ();
Greg Kroah-Hartman
maintainerPATCH 619/809 KVM: PPC: Book3S HV nestedv2: Add DPDES support in helper library for Guest state buffer
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <[email protected]>
commit 55dfb8bed6fe8bda390cc71cca878d11a9407099 upstream.
Add support for using DPDES in the library for using guest state buffers. DPDES support is needed for enabling usage of doorbells in a L2 KVM on PAPR guest.
--- Documentation/arch/powerpc/kvm-nested.rst | 4 +++- arch/powerpc/include/asm/guest-state-buffer.h | 3 ++- arch/powerpc/include/asm/kvm_book3s.h | 1 + arch/powerpc/kvm/book3s_hv_nestedv2.c | 7 +++++++ arch/powerpc/kvm/test-guest-state-buffer.c | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-)
Documentation/arch/powerpc/kvm-nested.rst +3 -1
@@ -546,7 +546,9 @@ table information. +--------+-------+----+--------+----------------------------------+ | 0x1052 | 0x08 | RW | T | CTRL | +--------+-------+----+--------+----------------------------------+ -| 0x1053-| | | | Reserved | +| 0x1053 | 0x08 | RW | T | DPDES | ++--------+-------+----+--------+----------------------------------+ +| 0x1054-| | | | Reserved | | 0x1FFF | | | | | +--------+-------+----+--------+----------------------------------+ | 0x2000 | 0x04 | RW | T | CR |
arch/powerpc/include/asm/guest-state-buffer.h +2 -1
@@ -81,6 +81,7 @@#define KVMPPC_GSID_HASHKEYR 0x1050#define KVMPPC_GSID_HASHPKEYR 0x1051#define KVMPPC_GSID_CTRL 0x1052 +#define KVMPPC_GSID_DPDES 0x1053#define KVMPPC_GSID_CR 0x2000#define KVMPPC_GSID_PIDR 0x2001
@@ -110,7 +111,7 @@#define KVMPPC_GSE_META_COUNT (KVMPPC_GSE_META_END - KVMPPC_GSE_META_START + 1)#define KVMPPC_GSE_DW_REGS_START KVMPPC_GSID_GPR(0) -#define KVMPPC_GSE_DW_REGS_END KVMPPC_GSID_CTRL +#define KVMPPC_GSE_DW_REGS_END KVMPPC_GSID_DPDES#define KVMPPC_GSE_DW_REGS_COUNT \ (KVMPPC_GSE_DW_REGS_END - KVMPPC_GSE_DW_REGS_START + 1)
arch/powerpc/include/asm/kvm_book3s.h +1 -0
@@ -594,6 +594,7 @@ static inline u##size kvmppc_get_##reg(s KVMPPC_BOOK3S_VCORE_ACCESSOR(vtb, 64, KVMPPC_GSID_VTB) +KVMPPC_BOOK3S_VCORE_ACCESSOR(dpdes, 64, KVMPPC_GSID_DPDES) KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(arch_compat, 32, KVMPPC_GSID_LOGICAL_PVR) KVMPPC_BOOK3S_VCORE_ACCESSOR_GET(lpcr, 64, KVMPPC_GSID_LPCR)KVMPPC_BOOK3S_VCORE_ACCESSOR_SET (tb_offset,64 ,KVMPPC_GSID_TB_OFFSET )
arch/powerpc/kvm/book3s_hv_nestedv2.c +7 -0
@@ -311,6 +311,10 @@ static int gs_msg_ops_vcpu_fill_info(str rc =kvmppc_gse_put_u64 (gsb, iden, vcpu->arch.vcore->vtb);break ; +case KVMPPC_GSID_DPDES : + rc =kvmppc_gse_put_u64 (gsb, iden, + vcpu->arch.vcore->dpdes); +break ;case KVMPPC_GSID_LPCR : rc =kvmppc_gse_put_u64 (gsb, iden, vcpu->arch.vcore->lpcr);
@@ -543,6 +547,9 @@ static int gs_msg_ops_vcpu_refresh_info(case KVMPPC_GSID_VTB : vcpu->arch.vcore->vtb =kvmppc_gse_get_u64 (gse);break ; +case KVMPPC_GSID_DPDES : + vcpu->arch.vcore->dpdes =kvmppc_gse_get_u64 (gse); +break ;case KVMPPC_GSID_LPCR : vcpu->arch.vcore->lpcr =kvmppc_gse_get_u64 (gse);break ;
arch/powerpc/kvm/test-guest-state-buffer.c +1 -1
@@ -151,7 +151,7 @@ static void test_gs_bitmap(struct kunit i++; } -for (u16 iden =KVMPPC_GSID_GPR (0 ); iden <=KVMPPC_GSID_CTRL ; iden++) { +for (u16 iden =KVMPPC_GSID_GPR (0 ); iden <=KVMPPC_GSE_DW_REGS_END ; iden++) {kvmppc_gsbm_set (&gsbm, iden);kvmppc_gsbm_set (&gsbm1, iden);KUNIT_EXPECT_TRUE (test,kvmppc_gsbm_test (&gsbm, iden));
Greg Kroah-Hartman
maintainerPATCH 620/809 KVM: VMX: Split out the non-virtualization part of vmx_interrupt_blocked()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 322a569c4b4188a0da2812f9e952780ce09b74ba upstream.
Move the non-VMX chunk of the "interrupt blocked" checks to a separate helper so that KVM can reuse the code to detect if interrupts are blocked for L2, e.g. to determine if a virtual interrupt _for L2_ is a valid wake event. If L1 disables HLT-exiting for L2, nested APICv is enabled, and L2 HLTs, then L2 virtual interrupts are valid wake events, but if and only if interrupts are unblocked for L2.
--- arch/x86/kvm/vmx/vmx.c | 11 ++++++++--- arch/x86/kvm/vmx/vmx.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-)
arch/x86/kvm/vmx/vmx.c +8 -3
@@ -5052,14 +5052,19 @@ int vmx_nmi_allowed(struct kvm_vcpu *vcpreturn !vmx_nmi_blocked (vcpu); } +bool __vmx_interrupt_blocked (struct kvm_vcpu *vcpu) +{ +return !(vmx_get_rflags (vcpu) &X86_EFLAGS_IF ) || + (vmcs_read32 (GUEST_INTERRUPTIBILITY_INFO ) & + (GUEST_INTR_STATE_STI |GUEST_INTR_STATE_MOV_SS )); +} +bool vmx_interrupt_blocked (struct kvm_vcpu *vcpu) {if (is_guest_mode (vcpu) &&nested_exit_on_intr (vcpu))return false; -return !(vmx_get_rflags (vcpu) &X86_EFLAGS_IF ) || - (vmcs_read32 (GUEST_INTERRUPTIBILITY_INFO ) & - (GUEST_INTR_STATE_STI |GUEST_INTR_STATE_MOV_SS )); +return __vmx_interrupt_blocked (vcpu); }int vmx_interrupt_allowed (struct kvm_vcpu *vcpu,bool for_injection)
arch/x86/kvm/vmx/vmx.h +1 -0
@@ -406,6 +406,7 @@ u64 construct_eptp(struct kvm_vcpu *vcpubool vmx_guest_inject_ac (struct kvm_vcpu *vcpu);void vmx_update_exception_bitmap (struct kvm_vcpu *vcpu);bool vmx_nmi_blocked (struct kvm_vcpu *vcpu); +bool __vmx_interrupt_blocked (struct kvm_vcpu *vcpu);bool vmx_interrupt_blocked (struct kvm_vcpu *vcpu);bool vmx_get_nmi_mask (struct kvm_vcpu *vcpu);void vmx_set_nmi_mask (struct kvm_vcpu *vcpu,bool masked);
Greg Kroah-Hartman
maintainerPATCH 621/809 KVM: nVMX: Add a helper to get highest pending from Posted Interrupt vector
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit d83c36d822be44db4bad0c43bea99c8908f54117 upstream.
Add a helper to retrieve the highest pending vector given a Posted Interrupt descriptor. While the actual operation is straightforward, it's surprisingly easy to mess up, e.g. if one tries to reuse lapic.c's find_highest_vector(), which doesn't work with PID.PIR due to the APIC's IRR and ISR component registers being physically discontiguous (they're 4-byte registers aligned at 16-byte intervals).
To make PIR handling more consistent with respect to IRR and ISR handling, return -1 to indicate "no interrupt pending".
--- arch/x86/kvm/vmx/nested.c | 5 +++-- arch/x86/kvm/vmx/posted_intr.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/nested.c +3 -2
@@ -12,6 +12,7 @@#include "mmu.h" #include "nested.h" #include "pmu.h" +#include "posted_intr.h" #include "sgx.h" #include "trace.h" #include "vmx.h"
@@ -3899,8 +3900,8 @@ static int vmx_complete_nested_posted_inif (!pi_test_and_clear_on (vmx->nested.pi_desc))return 0 ; - max_irr =find_last_bit ((unsigned long *)vmx->nested.pi_desc->pir,256 ); -if (max_irr !=256 ) { + max_irr =pi_find_highest_vector (vmx->nested.pi_desc); +if (max_irr >0 ) { vapic_page = vmx->nested.virtual_apic_map.hva;if (!vapic_page) goto mmio_needed;
arch/x86/kvm/vmx/posted_intr.h +10 -0
@@ -1,6 +1,8 @@/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __KVM_X86_VMX_POSTED_INTR_H#define __KVM_X86_VMX_POSTED_INTR_H + +#include <linux/find.h> #include <asm/posted_intr.h> void vmx_vcpu_pi_load (struct kvm_vcpu *vcpu,int cpu);
@@ -12,4 +14,12 @@ int vmx_pi_update_irte(struct kvm *kvm, uint32_t guest_irq, bool set);void vmx_pi_start_assignment (struct kvm *kvm); +static inline int pi_find_highest_vector (struct pi_desc *pi_desc) +{ +int vec; + + vec =find_last_bit ((unsigned long *)pi_desc->pir,256 ); +return vec <256 ? vec :-1 ; +} +#endif /* __KVM_X86_VMX_POSTED_INTR_H */
Greg Kroah-Hartman
maintainerPATCH 622/809 KVM: nVMX: Request immediate exit iff pending nested event needs injection
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 32f55e475ce2c4b8b124d335fcfaf1152ba977a1 upstream.
When requesting an immediate exit from L2 in order to inject a pending event, do so only if the pending event actually requires manual injection, i.e. if and only if KVM actually needs to regain control in order to deliver the event.
Avoiding the "immediate exit" isn't simply an optimization, it's necessary to make forward progress, as the "already expired" VMX preemption timer trick that KVM uses to force a VM-Exit has higher priority than events that aren't directly injected.
At present time, this is a glorified nop as all events processed by vmx_has_nested_events() require injection, but that will not hold true in the future, e.g. if there's a pending virtual interrupt in vmcs02.RVI. I.e. if KVM is trying to deliver a virtual interrupt to L2, the expired VMX preemption timer will trigger VM-Exit before the virtual interrupt is delivered, and KVM will effectively hang the vCPU in an endless loop of forced immediate VM-Exits (because the pending virtual interrupt never goes away).
--- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/x86.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -1
@@ -1819,7 +1819,7 @@ struct kvm_x86_nested_ops {bool (*is_exception_vmexit)(struct kvm_vcpu *vcpu,u8 vector,u32 error_code);int (*check_events)(struct kvm_vcpu *vcpu); -bool (*has_events)(struct kvm_vcpu *vcpu); +bool (*has_events)(struct kvm_vcpu *vcpu,bool for_injection);void (*triple_fault)(struct kvm_vcpu *vcpu); int (*get_state)(struct kvm_vcpu *vcpu, struct kvm_nested_state __user *user_kvm_nested_state,
arch/x86/kvm/vmx/nested.c +1 -1
@@ -4032,7 +4032,7 @@ static bool nested_vmx_preemption_timer_to_vmx (vcpu)->nested.preemption_timer_expired; } -static bool vmx_has_nested_events (struct kvm_vcpu *vcpu) +static bool vmx_has_nested_events (struct kvm_vcpu *vcpu,bool for_injection) {return nested_vmx_preemption_timer_pending (vcpu) ||to_vmx (vcpu)->nested.mtf_pending;
arch/x86/kvm/x86.c +2 -2
@@ -10516,7 +10516,7 @@ static int kvm_check_and_inject_events(sif (is_guest_mode (vcpu) && kvm_x86_ops.nested_ops->has_events && - kvm_x86_ops.nested_ops->has_events (vcpu)) + kvm_x86_ops.nested_ops->has_events (vcpu, true)) *req_immediate_exit = true;/*
@@ -13146,7 +13146,7 @@ static inline bool kvm_vcpu_has_events(sif (is_guest_mode (vcpu) && kvm_x86_ops.nested_ops->has_events && - kvm_x86_ops.nested_ops->has_events (vcpu)) + kvm_x86_ops.nested_ops->has_events (vcpu, false))return true;if (kvm_xen_has_pending_events (vcpu))
Greg Kroah-Hartman
maintainerPATCH 623/809 KVM: nVMX: Check for pending posted interrupts when looking for nested events
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 27c4fa42b11af780d49ce704f7fa67b3c2544df4 upstream.
Check for pending (and notified!) posted interrupts when checking if L2 has a pending wake event, as fully posted/notified virtual interrupt is a valid wake event for HLT.
Note that KVM must check vmx->nested.pi_pending to avoid prematurely waking L2, e.g. even if KVM sees a non-zero PID.PIR and PID.0N=1, the virtual interrupt won't actually be recognized until a notification IRQ is received by the vCPU or the vCPU does (nested) VM-Enter.
--- arch/x86/kvm/vmx/nested.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/nested.c +34 -2
@@ -4034,8 +4034,40 @@ static bool nested_vmx_preemption_timer_static bool vmx_has_nested_events (struct kvm_vcpu *vcpu,bool for_injection) { -return nested_vmx_preemption_timer_pending (vcpu) || -to_vmx (vcpu)->nested.mtf_pending; +struct vcpu_vmx *vmx =to_vmx (vcpu); +void *vapic = vmx->nested.virtual_apic_map.hva; +int max_irr, vppr; + +if (nested_vmx_preemption_timer_pending (vcpu) || + vmx->nested.mtf_pending) +return true; + +/* +* Virtual Interrupt Delivery doesn't require manual injection. Either +* the interrupt is already in GUEST_RVI and will be recognized by CPU +* at VM-Entry, or there is a KVM_REQ_EVENT pending and KVM will move +* the interrupt from the PIR to RVI prior to entering the guest. +*/ +if (for_injection) +return false; + +if (!nested_cpu_has_vid (get_vmcs12 (vcpu)) || +__vmx_interrupt_blocked (vcpu)) +return false; + +if (!vapic) +return false; + + vppr = *((u32 *)(vapic +APIC_PROCPRI )); + +if (vmx->nested.pi_pending && vmx->nested.pi_desc && +pi_test_on (vmx->nested.pi_desc)) { + max_irr =pi_find_highest_vector (vmx->nested.pi_desc); +if (max_irr >0 && (max_irr &0xf0 ) > (vppr &0xf0 )) +return true; + } + +return false; }/*
Greg Kroah-Hartman
maintainerPATCH 624/809 KVM: nVMX: Fold requested virtual interrupt check into has_nested_events()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 321ef62b0c5f6f57bb8500a2ca5986052675abbf upstream.
Check for a Requested Virtual Interrupt, i.e. a virtual interrupt that is pending delivery, in vmx_has_nested_events() and drop the one-off kvm_x86_ops.guest_apic_has_interrupt() hook.
In addition to dropping a superfluous hook, this fixes a bug where KVM would incorrectly treat virtual interrupts _for L2_ as always enabled due to kvm_arch_interrupt_allowed(), by way of vmx_interrupt_blocked(), treating IRQs as enabled if L2 is active and vmcs12 is configured to exit on IRQs, i.e. KVM would treat a virtual interrupt for L2 as a valid wake event based on L1's IRQ blocking status.
--- arch/x86/include/asm/kvm-x86-ops.h | 1 - arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx/main.c | 1 - arch/x86/kvm/vmx/nested.c | 4 ++++ arch/x86/kvm/vmx/vmx.c | 20 -------------------- arch/x86/kvm/vmx/x86_ops.h | 1 - arch/x86/kvm/x86.c | 10 +--------- 7 files changed, 5 insertions(+), 33 deletions(-)
arch/x86/include/asm/kvm-x86-ops.h +0 -1
@@ -85,7 +85,6 @@ KVM_X86_OP_OPTIONAL(update_cr8_intercept KVM_X86_OP(refresh_apicv_exec_ctrl) KVM_X86_OP_OPTIONAL(hwapic_irr_update) KVM_X86_OP_OPTIONAL(hwapic_isr_update) -KVM_X86_OP_OPTIONAL_RET0(guest_apic_has_interrupt) KVM_X86_OP_OPTIONAL(load_eoi_exitmap) KVM_X86_OP_OPTIONAL(set_virtual_apic_mode) KVM_X86_OP_OPTIONAL(set_apic_access_page_addr)
arch/x86/include/asm/kvm_host.h +0 -1
@@ -1714,7 +1714,6 @@ struct kvm_x86_ops {void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu);void (*hwapic_irr_update)(struct kvm_vcpu *vcpu,int max_irr);void (*hwapic_isr_update)(int isr); -bool (*guest_apic_has_interrupt)(struct kvm_vcpu *vcpu);void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu,u64 *eoi_exit_bitmap);void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu);void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu);
arch/x86/kvm/vmx/main.c +0 -1
@@ -97,7 +97,6 @@ struct kvm_x86_ops vt_x86_ops __initdata .required_apicv_inhibits = VMX_REQUIRED_APICV_INHIBITS, .hwapic_irr_update = vmx_hwapic_irr_update, .hwapic_isr_update = vmx_hwapic_isr_update, - .guest_apic_has_interrupt = vmx_guest_apic_has_interrupt, .sync_pir_to_irr = vmx_sync_pir_to_irr, .deliver_interrupt = vmx_deliver_interrupt, .dy_apicv_has_pending_interrupt = pi_has_pending_interrupt,
arch/x86/kvm/vmx/nested.c +4 -0
@@ -4060,6 +4060,10 @@ static bool vmx_has_nested_events(struct vppr = *((u32 *)(vapic +APIC_PROCPRI )); + max_irr =vmx_get_rvi (); +if ((max_irr &0xf0 ) > (vppr &0xf0 )) +return true; +if (vmx->nested.pi_pending && vmx->nested.pi_desc &&pi_test_on (vmx->nested.pi_desc)) { max_irr =pi_find_highest_vector (vmx->nested.pi_desc);
arch/x86/kvm/vmx/vmx.c +0 -20
@@ -4108,26 +4108,6 @@ void pt_update_intercept_for_msr(struct } } -bool vmx_guest_apic_has_interrupt (struct kvm_vcpu *vcpu) -{ -struct vcpu_vmx *vmx =to_vmx (vcpu); -void *vapic_page; -u32 vppr; -int rvi; - -if (WARN_ON_ONCE (!is_guest_mode (vcpu)) || - !nested_cpu_has_vid (get_vmcs12 (vcpu)) || -WARN_ON_ONCE (!vmx->nested.virtual_apic_map.gfn)) -return false; - - rvi =vmx_get_rvi (); - - vapic_page = vmx->nested.virtual_apic_map.hva; - vppr = *((u32 *)(vapic_page +APIC_PROCPRI )); - -return ((rvi &0xf0 ) > (vppr &0xf0 )); -} -void vmx_msr_filter_changed (struct kvm_vcpu *vcpu) {struct vcpu_vmx *vmx =to_vmx (vcpu);
arch/x86/kvm/vmx/x86_ops.h +0 -1
@@ -49,7 +49,6 @@ void vmx_apicv_pre_state_restore(structbool vmx_check_apicv_inhibit_reasons (enum kvm_apicv_inhibit reason);void vmx_hwapic_irr_update (struct kvm_vcpu *vcpu,int max_irr);void vmx_hwapic_isr_update (int max_isr); -bool vmx_guest_apic_has_interrupt (struct kvm_vcpu *vcpu);int vmx_sync_pir_to_irr (struct kvm_vcpu *vcpu);void vmx_deliver_interrupt (struct kvm_lapic *apic,int delivery_mode,int trig_mode,int vector);
arch/x86/kvm/x86.c +1 -9
@@ -13100,12 +13100,6 @@ void kvm_arch_commit_memory_region(struckvm_arch_free_memslot (kvm, old); } -static inline bool kvm_guest_apic_has_interrupt (struct kvm_vcpu *vcpu) -{ -return (is_guest_mode (vcpu) && -static_call (kvm_x86_guest_apic_has_interrupt)(vcpu)); -} -static inline bool kvm_vcpu_has_events (struct kvm_vcpu *vcpu) {if (!list_empty_careful (&vcpu->async_pf.done))
@@ -13136,9 +13130,7 @@ static inline bool kvm_vcpu_has_events(sif (kvm_test_request (KVM_REQ_PMI , vcpu))return true; -if (kvm_arch_interrupt_allowed (vcpu) && - (kvm_cpu_has_interrupt (vcpu) || -kvm_guest_apic_has_interrupt (vcpu))) +if (kvm_arch_interrupt_allowed (vcpu) &&kvm_cpu_has_interrupt (vcpu))return true;if (kvm_hv_has_stimer_pending (vcpu))
Greg Kroah-Hartman
maintainerPATCH 625/809 ALSA: hda/realtek: cs35l41: Fixup remaining asus strix models
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luke D. Jones <[email protected]>
commit e6e18021ddd0dc5af487fb86b6d7c964e062d692 upstream.
Adjust quirks for 0x3a20, 0x3a30, 0x3a50 to match the 0x3a60. This set has now been confirmed to work with this patch.
--- sound/pci/hda/patch_realtek.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/pci/hda/patch_realtek.c +3 -3
@@ -10360,10 +10360,10 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1043 ,0x1f62 ,"ASUS UX7602ZM" ,ALC245_FIXUP_CS35L41_SPI_2 ),SND_PCI_QUIRK (0x1043 ,0x1f92 ,"ASUS ROG Flow X16" ,ALC289_FIXUP_ASUS_GA401 ),SND_PCI_QUIRK (0x1043 ,0x3030 ,"ASUS ZN270IE" ,ALC256_FIXUP_ASUS_AIO_GPIO2 ), -SND_PCI_QUIRK (0x1043 ,0x3a20 ,"ASUS G614JZR" ,ALC245_FIXUP_CS35L41_SPI_2 ), -SND_PCI_QUIRK (0x1043 ,0x3a30 ,"ASUS G814JVR/JIR" ,ALC245_FIXUP_CS35L41_SPI_2 ), +SND_PCI_QUIRK (0x1043 ,0x3a20 ,"ASUS G614JZR" ,ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS ), +SND_PCI_QUIRK (0x1043 ,0x3a30 ,"ASUS G814JVR/JIR" ,ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS ),SND_PCI_QUIRK (0x1043 ,0x3a40 ,"ASUS G814JZR" ,ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS ), -SND_PCI_QUIRK (0x1043 ,0x3a50 ,"ASUS G834JYR/JZR" ,ALC245_FIXUP_CS35L41_SPI_2 ), +SND_PCI_QUIRK (0x1043 ,0x3a50 ,"ASUS G834JYR/JZR" ,ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS ),SND_PCI_QUIRK (0x1043 ,0x3a60 ,"ASUS G634JYR/JZR" ,ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS ),SND_PCI_QUIRK (0x1043 ,0x831a ,"ASUS P901" ,ALC269_FIXUP_STEREO_DMIC ), SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
Greg Kroah-Hartman
maintainerPATCH 626/809 ALSA: firewire-lib: fix wrong value as length of header for CIP_NO_HEADER case
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
commit c1839501fe3e67d98635f159dba8b170d08f6521 upstream.
In a commit 1d717123bb1a ("ALSA: firewire-lib: Avoid -Wflex-array-member-not-at-end warning"), DEFINE_FLEX() macro was used to handle variable length of array for header field in struct fw_iso_packet structure. The usage of macro has a side effect that the designated initializer assigns the count of array to the given field. Therefore CIP_HEADER_QUADLETS (=2) is assigned to struct fw_iso_packet.header, while the original designated initializer assigns zero to all fields.
With CIP_NO_HEADER flag, the change causes invalid length of header in isochronous packet for 1394 OHCI IT context. This bug affects all of devices supported by ALSA fireface driver; RME Fireface 400, 800, UCX, UFX, and 802.
This commit fixes the bug by replacing it with the alternative version of macro which corresponds no initializer.
--- sound/firewire/amdtp-stream.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/firewire/amdtp-stream.c +1 -2
@@ -1180,8 +1180,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ (void )fw_card_read_cycle_time (fw_parent_device (s->unit)->card, &curr_cycle_time);for (i =0 ; i < packets; ++i) { - DEFINE_FLEX(struct fw_iso_packet, template, header, - header_length, CIP_HEADER_QUADLETS); + DEFINE_RAW_FLEX(struct fw_iso_packet, template, header, CIP_HEADER_QUADLETS);bool sched_irq = false; build_it_pkt_header(s, desc->cycle, template, pkt_header_length,
Signature · 1 line
2.45.2
Greg Kroah-Hartman
maintainerPATCH 627/809 ALSA: ump: Dont update FB name for static blocks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 9a4ab167cfb1dea1df0c0c948205a62c7eb3b85b upstream.
When a device tries to update the FB name string even if its Endpoint is declared as static, we should skip it, just already done for the FB info update reply.
--- sound/core/ump.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/core/ump.c +7 -0
@@ -806,6 +806,13 @@ static int ump_handle_fb_name_msg(structif (!fb)return -ENODEV ; +if (ump->parsed && + (ump->info.flags &SNDRV_UMP_EP_INFO_STATIC_BLOCKS )) { +ump_dbg (ump,"Skipping static FB name update (blk#%d)\n" , + fb->info.block_id); +return 0 ; + } + ret =ump_append_string (ump, fb->info.name,sizeof (fb->info.name), buf->raw,3 );/* notify the FB name update to sequencer, too */
Greg Kroah-Hartman
maintainerPATCH 628/809 ALSA: ump: Force 1 Group for MIDI1 FBs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit ac29d8ae05b770ed3f52d7a60908ab9b126f69d7 upstream.
When a Function Block declares it being a legacy MIDI1 device, it has to be only with a single UMP Group. Correct the attribute when a device declares it wrongly.
--- sound/core/ump.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/core/ump.c +6 -0
@@ -733,6 +733,12 @@ static void fill_fb_info(struct snd_ump_ info->block_id, info->direction, info->active, info->first_group, info->num_groups, info->midi_ci_version, info->sysex8_streams, info->flags); + +if ((info->flags &SNDRV_UMP_BLOCK_IS_MIDI1 ) && info->num_groups !=1 ) { + info->num_groups =1 ; +ump_dbg (ump,"FB %d: corrected groups to 1 for MIDI1\n" , + info->block_id); + } }/* check whether the FB info gets updated by the current message */
Greg Kroah-Hartman
maintainerPATCH 629/809 ALSA: usb-audio: Fix microphone sound on HD webcam.
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
commit 74dba240881820b46b9b1c62ef4de3bfff47fbd4 upstream.
I own an external usb Webcam, HD webcam, which had low mic volume and inconsistent sound quality. Video works as expected.
(snip)
[ 95.473820][ 1] [ T73] usb 5-2.2: new high-speed USB device number 7 using xhci_hcd [ 95.773974][ 1] [ T73] usb 5-2.2: New USB device found, idVendor=1bcf, idProduct=2281, bcdDevice= 0.05 [ 95.783445][ 1] [ T73] usb 5-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 95.791872][ 1] [ T73] usb 5-2.2: Product: HD webcam [ 95.797001][ 1] [ T73] usb 5-2.2: Manufacturer: Sunplus IT Co [ 95.802996][ 1] [ T73] usb 5-2.2: SerialNumber: 20200513 [ 96.092610][ 2] [ T3680] usb 5-2.2: Warning! Unlikely big volume range (=4096), cval->res is probably wrong. [ 96.102436][ 2] [ T3680] usb 5-2.2: [5] FU [Mic Capture Volume] ch = 1, val = 0/4096/1
Set up quirk cval->res to 16 for 256 levels,
Set GET_SAMPLE_RATE quirk flag to stop trying to get the sample rate. Confirmed that happened anyway later due to the backoff mechanism, After 3 failures.
All audio stream on device interfaces share the same values, apart from wMaxPacketSize and tSamFreq :
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 4
bNumEndpoints 1
bInterfaceClass 1 AudioInterface Descriptor:
bLength 9 bDescriptorType 4 bInterfaceNumber 3 bAlternateSetting 4 bNumEndpoints 1 bInterfaceClass 1 Audio bInterfaceSubClass 2 Streaming bInterfaceProtocol 0 iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 3
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 1
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x86 EP 6 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0064 1x 100 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000
(snip)
Testing patch provides consistent good sound recording quality and volume range.
(snip)
[ 95.473820][ 1] [ T73] usb 5-2.2: new high-speed USB device number 7 using xhci_hcd [ 95.773974][ 1] [ T73] usb 5-2.2: New USB device found, idVendor=1bcf, idProduct=2281, bcdDevice= 0.05 [ 95.783445][ 1] [ T73] usb 5-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 95.791872][ 1] [ T73] usb 5-2.2: Product: HD webcam [ 95.797001][ 1] [ T73] usb 5-2.2: Manufacturer: Sunplus IT Co [ 95.802996][ 1] [ T73] usb 5-2.2: SerialNumber: 20200513 [ 96.110630][ 3] [ T3680] usbcore: registered new interface driver snd-usb-audio [ 96.114329][ 7] [ T3677] usb 5-2.2: Found UVC 1.00 device HD webcam (1bcf:2281) [ 96.167555][ 7] [ T3677] usbcore: registered new interface driver uvcvideo
--- sound/usb/mixer.c | 7 +++++++ sound/usb/quirks.c | 2 ++ 2 files changed, 9 insertions(+)
sound/usb/mixer.c +7 -0
@@ -1211,6 +1211,13 @@ static void volume_control_quirks(struct cval->res =16 ; }break ; +case USB_ID (0x1bcf ,0x2281 ):/* HD Webcam */ +if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { +usb_audio_info (chip, +"set resolution quirk: cval->res = 16\n" ); + cval->res =16 ; + } +break ; } }
sound/usb/quirks.c +2 -0
@@ -2225,6 +2225,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_ALIGN_TRANSFER),DEVICE_FLG (0x534d ,0x2109 ,/* MacroSilicon MS2109 */ QUIRK_FLAG_ALIGN_TRANSFER ), +DEVICE_FLG (0x1bcf ,0x2281 ,/* HD Webcam */ +QUIRK_FLAG_GET_SAMPLE_RATE ),/* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */
Greg Kroah-Hartman
maintainerPATCH 630/809 ALSA: usb-audio: Move HD Webcam quirk to the right place
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 7010d9464f7ca3ee2d75095ea2e642a9009a41ff upstream.
The quirk_flags_table[] is sorted in the USB ID order, while the last fix was put at a wrong position. Adjust the entry at the right position.
--- sound/usb/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/quirks.c +2 -2
@@ -2167,6 +2167,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_GET_SAMPLE_RATE),DEVICE_FLG (0x19f7 ,0x0035 ,/* RODE NT-USB+ */ QUIRK_FLAG_GET_SAMPLE_RATE ), +DEVICE_FLG (0x1bcf ,0x2281 ,/* HD Webcam */ +QUIRK_FLAG_GET_SAMPLE_RATE ),DEVICE_FLG (0x1bcf ,0x2283 ,/* NexiGo N930AF FHD Webcam */ QUIRK_FLAG_GET_SAMPLE_RATE ), DEVICE_FLG(0x2040, 0x7200, /* Hauppauge HVR-950Q */
@@ -2225,8 +2227,6 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_ALIGN_TRANSFER),DEVICE_FLG (0x534d ,0x2109 ,/* MacroSilicon MS2109 */ QUIRK_FLAG_ALIGN_TRANSFER ), -DEVICE_FLG (0x1bcf ,0x2281 ,/* HD Webcam */ -QUIRK_FLAG_GET_SAMPLE_RATE ),/* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */
Greg Kroah-Hartman
maintainerPATCH 631/809 ALSA: usb-audio: Add a quirk for Sonix HD USB Camera
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
commit 21451dfd853e7d8e6e3fbd7ef1fbdb2f2ead12f5 upstream.
Sonix HD USB Camera does not support reading the sample rate which leads to many lines of "cannot get freq at ep 0x84".
This patch adds the USB ID to quirks.c and avoids those error messages.
(snip)
[1.789698] usb 3-3: new high-speed USB device number 2 using xhci_hcd [1.984121] usb 3-3: New USB device found, idVendor=0c45, idProduct=6340, bcdDevice= 0.00 [1.984124] usb 3-3: New USB device strings: Mfr=2, Product=1, SerialNumber=0 [1.984127] usb 3-3: Product: USB 2.0 Camera [1.984128] usb 3-3: Manufacturer: Sonix Technology Co., Ltd. [5.440957] usb 3-3: 3:1: cannot get freq at ep 0x84 [12.130679] usb 3-3: 3:1: cannot get freq at ep 0x84 [12.175065] usb 3-3: 3:1: cannot get freq at ep 0x84
--- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
@@ -2125,6 +2125,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_CTL_MSG_DELAY_1M),DEVICE_FLG (0x0b0e ,0x0349 ,/* Jabra 550a */ QUIRK_FLAG_CTL_MSG_DELAY_1M ), +DEVICE_FLG (0x0c45 ,0x6340 ,/* Sonix HD USB Camera */ +QUIRK_FLAG_GET_SAMPLE_RATE ),DEVICE_FLG (0x0ecb ,0x205c ,/* JBL Quantum610 Wireless */ QUIRK_FLAG_FIXED_RATE ), DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */
Greg Kroah-Hartman
maintainerPATCH 632/809 tools/memory-model: Fix bug in lock.cat
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 4c830eef806679dc243e191f962c488dd9d00708 upstream.
Andrea reported that the following innocuous litmus test:
C T
{}
P0(spinlock_t *x)
{
int r0;
spin_lock(x);
spin_unlock(x);
r0 = spin_is_locked(x);
}gives rise to a nonsensical empty result with no executions:
$ herd7 -conf linux-kernel.cfg T.litmus Test T Required States 0 Ok Witnesses Positive: 0 Negative: 0 Condition forall (true) Observation T Never 0 0 Time T 0.00 Hash=6fa204e139ddddf2cb6fa963bad117c0
The problem is caused by a bug in the lock.cat part of the LKMM. Its computation of the rf relation for RU (read-unlocked) events is faulty; it implicitly assumes that every RU event must read from either a UL (unlock) event in another thread or from the lock's initial state. Neither is true in the litmus test above, so the computation yields no possible executions.
The lock.cat code tries to make up for this deficiency by allowing RU events outside of critical sections to read from the last po-previous UL event. But it does this incorrectly, trying to keep these rfi links separate from the rfe links that might also be needed, and passing only the latter to herd7's cross() macro.
The problem is fixed by merging the two sets of possible rf links for RU events and using them all in the call to cross().
--- tools/memory-model/lock.cat | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
tools/memory-model/lock.cat +10 -10
@@ -102,19 +102,19 @@ let rf-lf = rfe-lf | rfi-lf * within one of the lock's critical sections returns False. *) -(* rfi for RU events: an RU may read from the last po-previous UL *) -let rfi-ru = ([UL] ; po-loc ; [RU]) \ ([UL] ; po-loc ; [LKW] ; po-loc) - -(* rfe for RU events: an RU may read from an external UL or the initial write *) -let all-possible-rfe-ru = - let possible-rfe-ru r = +(* + * rf for RU events: an RU may read from an external UL or the initial write, + * or from the last po-previous UL + *) +let all-possible-rf-ru = + let possible-rf-ru r = let pair-to-relation p = p ++ 0 - in map pair-to-relation (((UL | IW) * {r}) & loc & ext) - in map possible-rfe-ru RU + in map pair-to-relation ((((UL | IW) * {r}) & loc & ext) | + (((UL * {r}) & po-loc) \ ([UL] ; po-loc ; [LKW] ; po-loc))) + in map possible-rf-ru RU (* Generate all rf relations for RU events *) -with rfe-ru from cross(all-possible-rfe-ru) -let rf-ru = rfe-ru | rfi-ru +with rf-ru from cross(all-possible-rf-ru) (* Final rf relation *) let rf = rf | rf-lf | rf-ru
Greg Kroah-Hartman
maintainerPATCH 633/809 fbdev: vesafb: Detect VGA compatibility from screen infos VESA attributes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
commit c2bc958b2b03e361f14df99983bc64a39a7323a3 upstream.
Test the vesa_attributes field in struct screen_info for compatibility with VGA hardware. Vesafb currently tests bit 1 in screen_info's capabilities field which indicates a 64-bit lfb address and is unrelated to VGA compatibility.
Section 4.4 of the Vesa VBE 2.0 specifications defines that bit 5 in the mode's attributes field signals VGA compatibility. The mode is compatible with VGA hardware if the bit is clear. In that case, the driver can access VGA state of the VBE's underlying hardware. The vesafb driver uses this feature to program the color LUT in palette modes. Without, colors might be incorrect.
The problem got introduced in commit 89ec4c238e7a ("[PATCH] vesafb: Fix incorrect logo colors in x86_64"). It incorrectly stores the mode attributes in the screen_info's capabilities field and updates vesafb accordingly. Later, commit 5e8ddcbe8692 ("Video mode probing support for the new x86 setup code") fixed the screen_info, but did not update vesafb. Color output still tends to work, because bit 1 in capabilities is usually 0.
Besides fixing the bug in vesafb, this commit introduces a helper that reads the correct bit from screen_info.
--- drivers/video/fbdev/vesafb.c | 2 +- include/linux/screen_info.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/video/fbdev/vesafb.c +1 -1
@@ -271,7 +271,7 @@ static int vesafb_probe(struct platform_if (si->orig_video_isVGA !=VIDEO_TYPE_VLFB )return -ENODEV ; - vga_compat = (si->capabilities &2 ) ?0 :1 ; + vga_compat = !__screen_info_vbe_mode_nonvga (si); vesafb_fix.smem_start = si->lfb_base; vesafb_defined.bits_per_pixel = si->lfb_depth;if (15 == vesafb_defined.bits_per_pixel)
include/linux/screen_info.h +10 -0
@@ -49,6 +49,16 @@ static inline u64 __screen_info_lfb_sizereturn lfb_size; } +static inline bool __screen_info_vbe_mode_nonvga (const struct screen_info *si) +{ +/* +* VESA modes typically run on VGA hardware. Set bit 5 signals that this +* is not the case. Drivers can then not make use of VGA resources. See +* Sec 4.4 of the VBE 2.0 spec. +*/ +return si->vesa_attributes &BIT (5 ); +} +static inline unsigned int __screen_info_video_type (unsigned int type) {switch (type) {
Greg Kroah-Hartman
maintainerPATCH 634/809 drm/fbdev-dma: Fix framebuffer mode for big endian devices
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Huth <[email protected]>
commit cb31c58e8c294ff31ea842ee1fa2c06c9a9f1cc3 upstream.
The drm_mode_legacy_fb_format() function only generates formats suitable for little endian devices. switch to drm_driver_legacy_fb_format() here instead to take the device endianness into consideration, too.
--- drivers/gpu/drm/drm_fbdev_dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fbdev_dma.c +2 -1
@@ -90,7 +90,8 @@ static int drm_fbdev_dma_helper_fb_probe sizes->surface_width, sizes->surface_height, sizes->surface_bpp); - format =drm_mode_legacy_fb_format (sizes->surface_bpp, sizes->surface_depth); + format =drm_driver_legacy_fb_format (dev, sizes->surface_bpp, + sizes->surface_depth); buffer =drm_client_framebuffer_create (client, sizes->surface_width, sizes->surface_height, format);if (IS_ERR (buffer))
Greg Kroah-Hartman
maintainerPATCH 635/809 hwrng: amd - Convert PCIBIOS_* return codes to errnos
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit 14cba6ace79627a57fb9058582b03f0ed3832390 upstream.
amd_rng_mod_init() uses pci_read_config_dword() that returns PCIBIOS_* codes. The return code is then returned as is but amd_rng_mod_init() is a module_init() function that should return normal errnos.
Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.
--- drivers/char/hw_random/amd-rng.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/amd-rng.c +3 -1
@@ -143,8 +143,10 @@ static int __init amd_rng_mod_init(void) found: err =pci_read_config_dword (pdev,0x58 , &pmbase); -if (err) +if (err) { + err =pcibios_err_to_errno (err); goto put_dev; + } pmbase &=0x0000FF00 ;if (pmbase ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 636/809 parisc: Fix warning at drivers/pci/msi/msi.h:121
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit 4c29ab84cfec17081aae7a7a28f8d2c93c42dcae upstream.
Fix warning at drivers/pci/msi/msi.h:121.
Recently, I added a PCI to PCIe bridge adaptor and a PCIe NVME card to my rp3440. Then, I noticed this warning at boot:
WARNING: CPU: 0 PID: 10 at drivers/pci/msi/msi.h:121 pci_msi_setup_msi_irqs+0x68/0x90 CPU: 0 PID: 10 Comm: kworker/u32:0 Not tainted 6.9.7-parisc64 #1 Debian 6.9.7-1 Hardware name: 9000/800/rp3440 Workqueue: async async_run_entry_fn
We need to select PCI_MSI_ARCH_FALLBACKS when PCI_MSI is selected.
--- arch/parisc/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/parisc/Kconfig +1 -0
@@ -86,6 +86,7 @@ config PARISC select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS select TRACE_IRQFLAGS_SUPPORT select HAVE_FUNCTION_DESCRIPTORS if 64BIT + select PCI_MSI_ARCH_FALLBACKS if PCI_MSI help The PA-RISC microprocessor is designed by Hewlett-Packard and used
Greg Kroah-Hartman
maintainerPATCH 637/809 PCI/DPC: Fix use-after-free on concurrent DPC and hot-removal
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 11a1f4bc47362700fcbde717292158873fb847ed upstream.
Keith reports a use-after-free when a DPC event occurs concurrently to hot-removal of the same portion of the hierarchy:
The dpc_handler() awaits readiness of the secondary bus below the Downstream Port where the DPC event occurred. To do so, it polls the config space of the first child device on the secondary bus. If that child device is concurrently removed, accesses to its struct pci_dev cause the kernel to oops.
That's because pci_bridge_wait_for_secondary_bus() neglects to hold a reference on the child device. Before v6.3, the function was only called on resume from system sleep or on runtime resume. Holding a reference wasn't necessary back then because the pciehp IRQ thread could never run concurrently. (On resume from system sleep, IRQs are not enabled until after the resume_noirq phase. And runtime resume is always awaited before a PCI device is removed.)
However starting with v6.3, pci_bridge_wait_for_secondary_bus() is also called on a DPC event. Commit 53b54ad074de ("PCI/DPC: Await readiness of secondary bus after reset"), which introduced that, failed to appreciate that pci_bridge_wait_for_secondary_bus() now needs to hold a reference on the child device because dpc_handler() and pciehp may indeed run concurrently. The commit was backported to v5.10+ stable kernels, so that's the oldest one affected.
Add the missing reference acquisition.
Abridged stack trace:
BUG: unable to handle page fault for address: 00000000091400c0 CPU: 15 PID: 2464 Comm: irq/53-pcie-dpc 6.9.0 RIP: pci_bus_read_config_dword+0x17/0x50 pci_dev_wait() pci_bridge_wait_for_secondary_bus() dpc_reset_link() pcie_do_recovery() dpc_handler()
--- drivers/pci/pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/pci.c +3 -3
@@ -4753,7 +4753,7 @@ static int pci_bus_max_d3cold_delay(cons*/ int pci_bridge_wait_for_secondary_bus (struct pci_dev *dev,char *reset_type) { -struct pci_dev *child; + struct pci_dev *child __free(pci_dev_put) = NULL;int delay;if (pci_dev_is_disconnected (dev))
@@ -4782,8 +4782,8 @@ int pci_bridge_wait_for_secondary_bus(streturn 0 ; } - child = list_first_entry(&dev->subordinate->devices, struct pci_dev, - bus_list); + child =pci_dev_get (list_first_entry (&dev->subordinate->devices, + struct pci_dev, bus_list));up_read (&pci_bus_sem);/*
Greg Kroah-Hartman
maintainerPATCH 638/809 PCI: hv: Return zero, not garbage, when reading PCI_INTERRUPT_PIN
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Liu <[email protected]>
commit fea93a3e5d5e6a09eb153866d2ce60ea3287a70d upstream.
The intent of the code snippet is to always return 0 for both PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN.
The check misses PCI_INTERRUPT_PIN. This patch fixes that.
This is discovered by this call in VFIO:
pci_read_config_byte(vdev->pdev, PCI_INTERRUPT_PIN, &pin);
The old code does not set *val to 0 because it misses the check for PCI_INTERRUPT_PIN. Garbage is returned in that case.
--- drivers/pci/controller/pci-hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-hyperv.c +2 -2
@@ -1130,8 +1130,8 @@ static void _hv_pcifront_read_config(str PCI_CAPABILITY_LIST) {/* ROM BARs are unimplemented */ *val =0 ; - } else if (where >= PCI_INTERRUPT_LINE && where + size <= - PCI_INTERRUPT_PIN) { + } else if ((where >= PCI_INTERRUPT_LINE && where + size <= PCI_INTERRUPT_PIN) || + (where >= PCI_INTERRUPT_PIN && where + size <= PCI_MIN_GNT)) {/* * Interrupt Line and Interrupt PIN are hard-wired to zero * because this front-end only supports message-signaled