6.10.13-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 122/634 firmware: qcom: scm: Disable SDI and write no dump to dump mode
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 79cb2cb8d89b7eca87e8dac031dadea4aeafeaa7 ]
SDI is enabled for most of the Qualcomm SoCs and as per commit ff4aa3bc9825 ("firmware: qcom_scm: disable SDI if required") it was recommended to disable SDI by mentioning it in device tree to avoid hang during watchdog or during reboot.
However, for some cases if download mode tcsr register already configured from boot firmware to collect dumps and if SDI is disabled via means of mentioning it in device tree we could still end up with dump collection. Disabling SDI alone is not completely enough to disable dump mode and we also need to zero out the bits download bits from tcsr register.
Current commit now, unconditionally call qcom_scm_set_download_mode() based on download_mode flag, at max if TCSR register is not mentioned or available for a SoC it will fallback to legacy way of setting download mode through command which may be no-ops or return error in case current firmware does not implements QCOM_SCM_INFO_IS_CALL_AVAIL so, at worst it does nothing if it fails.
It also does to call SDI disable call if dload mode is disabled, which looks fine to do as intention is to disable dump collection even if system crashes.
--- drivers/firmware/qcom/qcom_scm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/firmware/qcom/qcom_scm.c +2 -4
@@ -1875,14 +1875,12 @@ static int qcom_scm_probe(struct platform_device *pdev)* will cause the boot stages to enter download mode, unless * disabled below by a clean shutdown/reboot. */ -if (download_mode) -qcom_scm_set_download_mode (true); - +qcom_scm_set_download_mode (download_mode);/* * Disable SDI if indicated by DT that it is enabled by default. */ -if (of_property_read_bool (pdev->dev.of_node,"qcom,sdi-enabled" )) +if (of_property_read_bool (pdev->dev.of_node,"qcom,sdi-enabled" ) || !download_mode)qcom_scm_disable_sdi ();/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 123/634 regulator: Return actual error in of_regulator_bulk_get_all()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 395a41a1d3e377462f3eea8a205ee72be8885ff6 ]
If regulator_get() in of_regulator_bulk_get_all() returns an error, that error gets overridden and -EINVAL is always passed out. This masks probe deferral requests and likely won't work properly in all cases.
Fix this by letting of_regulator_bulk_get_all() return the original error code.
--- drivers/regulator/of_regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/of_regulator.c +1 -1
@@ -777,7 +777,7 @@ int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, name[i] ='\0' ; tmp =regulator_get (dev, name);if (IS_ERR (tmp)) { - ret = -EINVAL ; + ret =PTR_ERR (tmp); goto error; } (*consumers)[n].consumer = tmp;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 124/634 arm64: dts: renesas: r9a08g045: Correct GICD and GICR sizes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit ec9532628eb9d82282b8e52fd9c4a3800d87feec ]
The RZ/G3S SoC is equipped with the GIC-600. The GICD is 64KiB + 64KiB for the MBI alias (in total 128KiB), and the GICR is 128KiB per CPU.
Despite the RZ/G3S SoC being single-core, it has two instances of GICR.
--- arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/renesas/r9a08g045.dtsi +2 -2
@@ -269,8 +269,8 @@ #interrupt-cells = <3>; #address-cells = <0>; interrupt-controller; - reg = <0x0 0x12400000 0 0x40000>, - <0x0 0x12440000 0 0x60000>; + reg = <0x0 0x12400000 0 0x20000>, + <0x0 0x12440000 0 0x40000>; interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 125/634 arm64: dts: renesas: r9a07g043u: Correct GICD and GICR sizes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit ab39547f739236e7f16b8b0a51fdca95cc9cadd3 ]
The RZ/G2UL SoC is equipped with the GIC-600. The GICD is 64KiB + 64KiB for the MBI alias (in total 128KiB), and the GICR is 128KiB per CPU.
Despite the RZ/G2UL SoC being single-core, it has two instances of GICR.
--- arch/arm64/boot/dts/renesas/r9a07g043u.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/renesas/r9a07g043u.dtsi +2 -2
@@ -210,8 +210,8 @@ #interrupt-cells = <3>; #address-cells = <0>; interrupt-controller; - reg = <0x0 0x11900000 0 0x40000>, - <0x0 0x11940000 0 0x60000>; + reg = <0x0 0x11900000 0 0x20000>, + <0x0 0x11940000 0 0x40000>; interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>; }; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 126/634 arm64: dts: renesas: r9a07g054: Correct GICD and GICR sizes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit 45afa9eacb59b258d2e53c7f63430ea1e8344803 ]
The RZ/V2L SoC is equipped with the GIC-600. The GICD is 64KiB + 64KiB for the MBI alias (in total 128KiB), and the GICR is 128KiB per CPU.
--- arch/arm64/boot/dts/renesas/r9a07g054.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/renesas/r9a07g054.dtsi +2 -2
@@ -1051,8 +1051,8 @@ #interrupt-cells = <3>; #address-cells = <0>; interrupt-controller; - reg = <0x0 0x11900000 0 0x40000>, - <0x0 0x11940000 0 0x60000>; + reg = <0x0 0x11900000 0 0x20000>, + <0x0 0x11940000 0 0x40000>; interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 127/634 arm64: dts: renesas: r9a07g044: Correct GICD and GICR sizes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit 833948fb2b63155847ab691a54800f801555429b ]
The RZ/G2L(C) SoC is equipped with the GIC-600. The GICD is 64KiB + 64KiB for the MBI alias (in total 128KiB), and the GICR is 128KiB per CPU.
--- arch/arm64/boot/dts/renesas/r9a07g044.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/renesas/r9a07g044.dtsi +2 -2
@@ -1043,8 +1043,8 @@ #interrupt-cells = <3>; #address-cells = <0>; interrupt-controller; - reg = <0x0 0x11900000 0 0x40000>, - <0x0 0x11940000 0 0x60000>; + reg = <0x0 0x11900000 0 0x20000>, + <0x0 0x11940000 0 0x40000>; interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 128/634 ARM: dts: microchip: sam9x60: Fix rtc/rtt clocks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Dahl <[email protected]>
[ Upstream commit d355c895fa4ddd8bec15569eee540baeed7df8c5 ]
The RTC and RTT peripherals use the timing domain slow clock (TD_SLCK), sourced from the 32.768 kHz crystal oscillator or slow rc oscillator.
The previously used Monitoring domain slow clock (MD_SLCK) is sourced from an internal RC oscillator which is most probably not precise enough for real time clock purposes.
[claudiu.beznea: removed () around the last commit description paragraph,
removed " in front of "timing domain slow clock", described that TD_SLCK can also be sourced from slow rc oscillator]
--- arch/arm/boot/dts/microchip/sam9x60.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/microchip/sam9x60.dtsi +2 -2
@@ -1312,7 +1312,7 @@ compatible = "microchip,sam9x60-rtt", "atmel,at91sam9260-rtt"; reg = <0xfffffe20 0x20>; interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>; - clocks = <&clk32k 0>; + clocks = <&clk32k 1>; }; pit: timer@fffffe40 {
@@ -1338,7 +1338,7 @@ compatible = "microchip,sam9x60-rtc", "atmel,at91sam9x5-rtc"; reg = <0xfffffea8 0x100>; interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>; - clocks = <&clk32k 0>; + clocks = <&clk32k 1>; }; watchdog: watchdog@ffffff80 {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 129/634 arm64: tegra: Correct location of power-sensors for IGX Orin
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Hunter <[email protected]>
[ Upstream commit b93679b8f165467e1584f9b23055db83f45c32ce ]
The power-sensors are located on the carrier board and not the module board and so update the IGX Orin device-tree files to fix this.
--- .../boot/dts/nvidia/tegra234-p3701-0008.dtsi | 33 ------------------- .../boot/dts/nvidia/tegra234-p3740-0002.dtsi | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234-p3701-0008.dtsi +0 -33
@@ -44,39 +44,6 @@ status = "okay"; }; - i2c@c250000 { - power-sensor@41 { - compatible = "ti,ina3221"; - reg = <0x41>; - #address-cells = <1>; - #size-cells = <0>; - - input@0 { - reg = <0x0>; - label = "CVB_ATX_12V"; - shunt-resistor-micro-ohms = <2000>; - }; - - input@1 { - reg = <0x1>; - label = "CVB_ATX_3V3"; - shunt-resistor-micro-ohms = <2000>; - }; - - input@2 { - reg = <0x2>; - label = "CVB_ATX_5V"; - shunt-resistor-micro-ohms = <2000>; - }; - }; - - power-sensor@44 { - compatible = "ti,ina219"; - reg = <0x44>; - shunt-resistor = <2000>; - }; - }; - rtc@c2a0000 { status = "okay"; };
arch/arm64/boot/dts/nvidia/tegra234-p3740-0002.dtsi +33 -0
@@ -183,6 +183,39 @@ phy-names = "usb2-0", "usb2-1", "usb2-2", "usb2-3", "usb3-0", "usb3-1", "usb3-2"; }; + + i2c@c250000 { + power-sensor@41 { + compatible = "ti,ina3221"; + reg = <0x41>; + #address-cells = <1>; + #size-cells = <0>; + + input@0 { + reg = <0x0>; + label = "CVB_ATX_12V"; + shunt-resistor-micro-ohms = <2000>; + }; + + input@1 { + reg = <0x1>; + label = "CVB_ATX_3V3"; + shunt-resistor-micro-ohms = <2000>; + }; + + input@2 { + reg = <0x2>; + label = "CVB_ATX_5V"; + shunt-resistor-micro-ohms = <2000>; + }; + }; + + power-sensor@44 { + compatible = "ti,ina219"; + reg = <0x44>; + shunt-resistor = <2000>; + }; + }; }; vdd_3v3_dp: regulator-vdd-3v3-dp {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 130/634 arm64: dts: rockchip: Correct vendor prefix for Hardkernel ODROID-M1
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Karlman <[email protected]>
[ Upstream commit 735065e774dcfc62e38df01a535862138b6c92ed ]
The vendor prefix for Hardkernel ODROID-M1 is incorrectly listed as rockchip. Use the proper hardkernel vendor prefix for this board, while at it also drop the redundant soc prefix.
--- arch/arm64/boot/dts/rockchip/rk3568-odroid-m1.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3568-odroid-m1.dts +1 -1
@@ -13,7 +13,7 @@ / { model = "Hardkernel ODROID-M1"; - compatible = "rockchip,rk3568-odroid-m1", "rockchip,rk3568"; + compatible = "hardkernel,odroid-m1", "rockchip,rk3568"; aliases { ethernet0 = &gmac0;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 131/634 arm64: dts: ti: k3-j721e-sk: Fix reversed C6x carveout locations
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 9f3814a7c06b7c7296cf8c1622078ad71820454b ]
The DMA carveout for the C6x core 0 is at 0xa6000000 and core 1 is at 0xa7000000. These are reversed in DT. While both C6x can access either region, so this is not normally a problem, but if we start restricting the memory each core can access (such as with firewalls) the cores accessing the regions for the wrong core will not work. Fix this here.
--- arch/arm64/boot/dts/ti/k3-j721e-sk.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/ti/k3-j721e-sk.dts +2 -2
@@ -119,7 +119,7 @@ no-map; }; - c66_1_dma_memory_region: c66-dma-memory@a6000000 { + c66_0_dma_memory_region: c66-dma-memory@a6000000 { compatible = "shared-dma-pool"; reg = <0x00 0xa6000000 0x00 0x100000>; no-map;
@@ -131,7 +131,7 @@ no-map; }; - c66_0_dma_memory_region: c66-dma-memory@a7000000 { + c66_1_dma_memory_region: c66-dma-memory@a7000000 { compatible = "shared-dma-pool"; reg = <0x00 0xa7000000 0x00 0x100000>; no-map;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 132/634 arm64: dts: ti: k3-j721e-beagleboneai64: Fix reversed C6x carveout locations
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 1a314099b7559690fe23cdf3300dfff6e830ecb1 ]
The DMA carveout for the C6x core 0 is at 0xa6000000 and core 1 is at 0xa7000000. These are reversed in DT. While both C6x can access either region, so this is not normally a problem, but if we start restricting the memory each core can access (such as with firewalls) the cores accessing the regions for the wrong core will not work. Fix this here.
--- arch/arm64/boot/dts/ti/k3-j721e-beagleboneai64.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/ti/k3-j721e-beagleboneai64.dts +2 -2
@@ -123,7 +123,7 @@ no-map; }; - c66_1_dma_memory_region: c66-dma-memory@a6000000 { + c66_0_dma_memory_region: c66-dma-memory@a6000000 { compatible = "shared-dma-pool"; reg = <0x00 0xa6000000 0x00 0x100000>; no-map;
@@ -135,7 +135,7 @@ no-map; }; - c66_0_dma_memory_region: c66-dma-memory@a7000000 { + c66_1_dma_memory_region: c66-dma-memory@a7000000 { compatible = "shared-dma-pool"; reg = <0x00 0xa7000000 0x00 0x100000>; no-map;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 133/634 spi: bcmbca-hsspi: Fix missing pm_runtime_disable()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 4439a2e92cb89028b22c5d7ba1b99e75d7d889f6 ]
The pm_runtime_disable() is missing in remove function, use devm_pm_runtime_enable() to fix it. So the pm_runtime_disable() in the probe error path can also be removed.
--- drivers/spi/spi-bcmbca-hsspi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-bcmbca-hsspi.c +4 -4
@@ -546,12 +546,14 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) goto out_put_host; } -pm_runtime_enable (&pdev->dev); + ret =devm_pm_runtime_enable (&pdev->dev); +if (ret) + goto out_put_host; ret =sysfs_create_group (&pdev->dev.kobj, &bcmbca_hsspi_group);if (ret) {dev_err (&pdev->dev,"couldn't register sysfs group\n" ); - goto out_pm_disable; + goto out_put_host; }/* register and we are done */
@@ -565,8 +567,6 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) out_sysgroup_disable:sysfs_remove_group (&pdev->dev.kobj, &bcmbca_hsspi_group); -out_pm_disable: -pm_runtime_disable (&pdev->dev); out_put_host:spi_controller_put (host); out_disable_pll_clk:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 134/634 arm64: dts: qcom: x1e80100: Fix PHY for DP2
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit ba728bda663b0e812cb20450d18af5d0edd803a2 ]
The actual PHY used by MDSS DP2 is the USB SS2 QMP one. So switch to it instead. This is needed to get external DP support on boards like CRD where the 3rd Type-C USB port (right-hand side) is connected to DP2.
--- arch/arm64/boot/dts/qcom/x1e80100.dtsi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/qcom/x1e80100.dtsi +5 -5
@@ -3998,14 +3998,14 @@ assigned-clocks = <&dispcc DISP_CC_MDSS_DPTX2_LINK_CLK_SRC>, <&dispcc DISP_CC_MDSS_DPTX2_PIXEL0_CLK_SRC>; - assigned-clock-parents = <&mdss_dp2_phy 0>, - <&mdss_dp2_phy 1>; + assigned-clock-parents = <&usb_1_ss2_qmpphy QMP_USB43DP_DP_LINK_CLK>, + <&usb_1_ss2_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>; operating-points-v2 = <&mdss_dp2_opp_table>; power-domains = <&rpmhpd RPMHPD_MMCX>; - phys = <&mdss_dp2_phy>; + phys = <&usb_1_ss2_qmpphy QMP_USB43DP_DP_PHY>; phy-names = "dp"; #sound-dai-cells = <0>;
@@ -4189,8 +4189,8 @@ <&usb_1_ss0_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>, <&usb_1_ss1_qmpphy QMP_USB43DP_DP_LINK_CLK>, /* dp1 */ <&usb_1_ss1_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>, - <&mdss_dp2_phy 0>, /* dp2 */ - <&mdss_dp2_phy 1>, + <&usb_1_ss2_qmpphy QMP_USB43DP_DP_LINK_CLK>, /* dp2 */ + <&usb_1_ss2_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>, <&mdss_dp3_phy 0>, /* dp3 */ <&mdss_dp3_phy 1>; power-domains = <&rpmhpd RPMHPD_MMCX>;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 135/634 ARM: dts: microchip: sama7g5: Fix RTT clock
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 867bf1923200e6ad82bad0289f43bf20b4ac7ff9 ]
According to datasheet, Chapter 34. Clock Generator, section 34.2, Embedded characteristics, source clock for RTT is the TD_SLCK, registered with ID 1 by the slow clock controller driver. Fix RTT clock.
--- arch/arm/boot/dts/microchip/sama7g5.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/microchip/sama7g5.dtsi +1 -1
@@ -272,7 +272,7 @@ compatible = "microchip,sama7g5-rtt", "microchip,sam9x60-rtt", "atmel,at91sam9260-rtt"; reg = <0xe001d020 0x30>; interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk32k 0>; + clocks = <&clk32k 1>; }; clk32k: clock-controller@e001d050 {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 136/634 ARM: dts: imx7d-zii-rmu2: fix Ethernet PHY pinctrl property
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 0e49cfe364dea4345551516eb2fe53135a10432b ]
There is no "fsl,phy" property in pin controller pincfg nodes:
imx7d-zii-rmu2.dtb: pinctrl@302c0000: enet1phyinterruptgrp: 'fsl,pins' is a required property imx7d-zii-rmu2.dtb: pinctrl@302c0000: enet1phyinterruptgrp: 'fsl,phy' does not match any of the regexes: 'pinctrl-[0-9]+'
--- arch/arm/boot/dts/nxp/imx/imx7d-zii-rmu2.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/nxp/imx/imx7d-zii-rmu2.dts +1 -1
@@ -350,7 +350,7 @@ &iomuxc_lpsr { pinctrl_enet1_phy_interrupt: enet1phyinterruptgrp { - fsl,phy = < + fsl,pins = < MX7D_PAD_LPSR_GPIO1_IO02__GPIO1_IO2 0x08 >; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 137/634 arm64: dts: ti: k3-am654-idk: Fix dtbs_check warning in ICSSG dmas
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: MD Danish Anwar <[email protected]>
[ Upstream commit 2bea7920da8001172f54359395700616269ccb70 ]
ICSSG doesn't use mgmnt rsp dmas. But these are added in the dmas for icssg1-eth and icssg0-eth node.
These mgmnt rsp dmas result in below dtbs_check warnings.
/workdir/arch/arm64/boot/dts/ti/k3-am654-idk.dtb: icssg1-eth: dmas: [[39, 49664], [39, 49665], [39, 49666], [39, 49667], [39, 49668], [39, 49669], [39, 49670], [39, 49671], [39, 16896], [39, 16897], [39, 16898], [39, 16899]] is too long
from schema $id: http://devicetree.org/schemas/net/ti,icssg-prueth.yaml#
/workdir/arch/arm64/boot/dts/ti/k3-am654-idk.dtb: icssg0-eth: dmas: [[39, 49408], [39, 49409], [39, 49410], [39, 49411], [39, 49412], [39, 49413], [39, 49414], [39, 49415], [39, 16640], [39, 16641], [39, 16642], [39, 16643]] is too long
from schema $id: http://devicetree.org/schemas/net/ti,icssg-prueth.yaml#
Fix these warnings by removing mgmnt rsp dmas from icssg1-eth and icssg0-eth nodes.
--- arch/arm64/boot/dts/ti/k3-am654-idk.dtso | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/ti/k3-am654-idk.dtso +2 -6
@@ -58,9 +58,7 @@ <&main_udmap 0xc107>, /* egress slice 1 */ <&main_udmap 0x4100>, /* ingress slice 0 */ - <&main_udmap 0x4101>, /* ingress slice 1 */ - <&main_udmap 0x4102>, /* mgmnt rsp slice 0 */ - <&main_udmap 0x4103>; /* mgmnt rsp slice 1 */ + <&main_udmap 0x4101>; /* ingress slice 1 */ dma-names = "tx0-0", "tx0-1", "tx0-2", "tx0-3", "tx1-0", "tx1-1", "tx1-2", "tx1-3", "rx0", "rx1";
@@ -126,9 +124,7 @@ <&main_udmap 0xc207>, /* egress slice 1 */ <&main_udmap 0x4200>, /* ingress slice 0 */ - <&main_udmap 0x4201>, /* ingress slice 1 */ - <&main_udmap 0x4202>, /* mgmnt rsp slice 0 */ - <&main_udmap 0x4203>; /* mgmnt rsp slice 1 */ + <&main_udmap 0x4201>; /* ingress slice 1 */ dma-names = "tx0-0", "tx0-1", "tx0-2", "tx0-3", "tx1-0", "tx1-1", "tx1-2", "tx1-3", "rx0", "rx1";
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 138/634 ARM: versatile: fix OF node leak in CPUs prepare
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f2642d97f2105ed17b2ece0c597450f2ff95d704 ]
Machine code is leaking OF node reference from of_find_matching_node() in realview_smp_prepare_cpus().
--- arch/arm/mach-versatile/platsmp-realview.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-versatile/platsmp-realview.c +1 -0
@@ -70,6 +70,7 @@ static void __init realview_smp_prepare_cpus(unsigned int max_cpus)return ; } map =syscon_node_to_regmap (np); +of_node_put (np);if (IS_ERR (map)) {pr_err ("PLATSMP: No syscon regmap\n" );return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 139/634 reset: berlin: fix OF node leak in probe() error path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 5f58a88cc91075be38cec69b7cb70aaa4ba69e8b ]
Driver is leaking OF node reference on memory allocation failure. Acquire the OF node reference after memory allocation to fix this and keep it simple.
--- drivers/reset/reset-berlin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/reset/reset-berlin.c +2 -1
@@ -68,13 +68,14 @@ static int berlin_reset_xlate(struct reset_controller_dev *rcdev,static int berlin2_reset_probe (struct platform_device *pdev) { -struct device_node *parent_np =of_get_parent (pdev->dev.of_node); +struct device_node *parent_np;struct berlin_reset_priv *priv; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ; + parent_np =of_get_parent (pdev->dev.of_node); priv->regmap =syscon_node_to_regmap (parent_np);of_node_put (parent_np);if (IS_ERR (priv->regmap))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 140/634 reset: k210: fix OF node leak in probe() error path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit b14e40f5dc7cd0dd7e958010e6ca9ad32ff2ddad ]
Driver is leaking OF node reference on memory allocation failure. Acquire the OF node reference after memory allocation to fix this and keep it simple.
--- drivers/reset/reset-k210.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/reset/reset-k210.c +2 -1
@@ -90,7 +90,7 @@ static const struct reset_control_ops k210_rst_ops = {static int k210_rst_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct device_node *parent_np =of_get_parent (dev->of_node); +struct device_node *parent_np;struct k210_rst *ksr;dev_info (dev,"K210 reset controller\n" );
@@ -99,6 +99,7 @@ static int k210_rst_probe(struct platform_device *pdev)if (!ksr)return -ENOMEM ; + parent_np =of_get_parent (dev->of_node); ksr->map =syscon_node_to_regmap (parent_np);of_node_put (parent_np);if (IS_ERR (ksr->map))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 141/634 clocksource/drivers/qcom: Add missing iounmap() on errors in msm_dt_timer_init()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ankit Agrawal <[email protected]>
[ Upstream commit ca140a0dc0a18acd4653b56db211fec9b2339986 ]
Add the missing iounmap() when clock frequency fails to get read by the of_property_read_u32() call, or if the call to msm_timer_init() fails.
--- drivers/clocksource/timer-qcom.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/clocksource/timer-qcom.c +6 -1
@@ -233,6 +233,7 @@ static int __init msm_dt_timer_init(struct device_node *np) }if (of_property_read_u32 (np,"clock-frequency" , &freq)) { +iounmap (cpu0_base);pr_err ("Unknown frequency\n" );return -EINVAL ; }
@@ -243,7 +244,11 @@ static int __init msm_dt_timer_init(struct device_node *np) freq /=4 ;writel_relaxed (DGT_CLK_CTL_DIV_4 , source_base +DGT_CLK_CTL ); -return msm_timer_init (freq,32 , irq, !!percpu_offset); + ret =msm_timer_init (freq,32 , irq, !!percpu_offset); +if (ret) +iounmap (cpu0_base); + +return ret; }TIMER_OF_DECLARE (kpss_timer,"qcom,kpss-timer" , msm_dt_timer_init);TIMER_OF_DECLARE (scss_timer,"qcom,scss-timer" , msm_dt_timer_init);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 142/634 arm64: dts: mediatek: mt8195: Correct clock order for dp_intf*
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 51bc68debab9e30b50c6352315950f3cfc309b32 ]
The clocks for dp_intf* device nodes are given in the wrong order, causing the binding validation to fail.
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +6 -6
@@ -3251,10 +3251,10 @@ compatible = "mediatek,mt8195-dp-intf"; reg = <0 0x1c015000 0 0x1000>; interrupts = <GIC_SPI 657 IRQ_TYPE_LEVEL_HIGH 0>; - clocks = <&vdosys0 CLK_VDO0_DP_INTF0>, - <&vdosys0 CLK_VDO0_DP_INTF0_DP_INTF>, + clocks = <&vdosys0 CLK_VDO0_DP_INTF0_DP_INTF>, + <&vdosys0 CLK_VDO0_DP_INTF0>, <&apmixedsys CLK_APMIXED_TVDPLL1>; - clock-names = "engine", "pixel", "pll"; + clock-names = "pixel", "engine", "pll"; status = "disabled"; };
@@ -3521,10 +3521,10 @@ reg = <0 0x1c113000 0 0x1000>; interrupts = <GIC_SPI 513 IRQ_TYPE_LEVEL_HIGH 0>; power-domains = <&spm MT8195_POWER_DOMAIN_VDOSYS1>; - clocks = <&vdosys1 CLK_VDO1_DP_INTF0_MM>, - <&vdosys1 CLK_VDO1_DPINTF>, + clocks = <&vdosys1 CLK_VDO1_DPINTF>, + <&vdosys1 CLK_VDO1_DP_INTF0_MM>, <&apmixedsys CLK_APMIXED_TVDPLL2>; - clock-names = "engine", "pixel", "pll"; + clock-names = "pixel", "engine", "pll"; status = "disabled"; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 143/634 x86/mm: Use IPIs to synchronize LAM enablement
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
[ Upstream commit 3b299b99556c1753923f8d9bbd9304bcd139282f ]
LAM can only be enabled when a process is single-threaded. But _kernel_ threads can temporarily use a single-threaded process's mm.
If LAM is enabled by a userspace process while a kthread is using its mm, the kthread will not observe LAM enablement (i.e. LAM will be disabled in CR3). This could be fine for the kthread itself, as LAM only affects userspace addresses. However, if the kthread context switches to a thread in the same userspace process, CR3 may or may not be updated because the mm_struct doesn't change (based on pending TLB flushes). If CR3 is not updated, the userspace thread will run incorrectly with LAM disabled, which may cause page faults when using tagged addresses. Example scenario:
CPU 1 CPU 2
/* kthread */kthread_use_mm()
/* user thread */
prctl_enable_tagged_addr()
/* LAM enabled on CPU 2 */
/* LAM disabled on CPU 1 */
context_switch() /* to CPU 1 *//* Switching to user thread */switch_mm_irqs_off()
/* CR3 not updated */
/* LAM is still disabled on CPU 1 */
Synchronize LAM enablement by sending an IPI to all CPUs running with the mm_struct to enable LAM. This makes sure LAM is enabled on CPU 1 in the above scenario before prctl_enable_tagged_addr() returns and userspace starts using tagged addresses, and before it's possible to run the userspace process on CPU 1.
In switch_mm_irqs_off(), move reading the LAM mask until after mm_cpumask() is updated. This ensures that if an outdated LAM mask is written to CR3, an IPI is received to update it right after IRQs are re-enabled.
[ dhansen: Add a LAM enabling helper and comment it ]
--- arch/x86/kernel/process_64.c | 29 ++++++++++++++++++++++++++--- arch/x86/mm/tlb.c | 7 +++---- 2 files changed, 29 insertions(+), 7 deletions(-)
arch/x86/kernel/process_64.c +26 -3
@@ -798,6 +798,27 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr)#define LAM_U57_BITS 6 +static void enable_lam_func (void *__mm) +{ +struct mm_struct *mm = __mm; + +if (this_cpu_read (cpu_tlbstate.loaded_mm) == mm) { +write_cr3 (__read_cr3 () | mm->context.lam_cr3_mask); +set_tlbstate_lam_mode (mm); + } +} + +static void mm_enable_lam (struct mm_struct *mm) +{ +/* +* Even though the process must still be single-threaded at this +* point, kernel threads may be using the mm. IPI those kernel +* threads if they exist. +*/ +on_each_cpu_mask (mm_cpumask (mm), enable_lam_func, mm, true); +set_bit (MM_CONTEXT_LOCK_LAM , &mm->context.flags); +} +static int prctl_enable_tagged_addr (struct mm_struct *mm,unsigned long nr_bits) {if (!cpu_feature_enabled (X86_FEATURE_LAM ))
@@ -814,6 +835,10 @@ static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)if (mmap_write_lock_killable (mm))return -EINTR ; +/* +* MM_CONTEXT_LOCK_LAM is set on clone. Prevent LAM from +* being enabled unless the process is single threaded: +*/ if (test_bit (MM_CONTEXT_LOCK_LAM , &mm->context.flags)) {mmap_write_unlock (mm);return -EBUSY ;
@@ -830,9 +855,7 @@ static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)return -EINVAL ; } -write_cr3 (__read_cr3 () | mm->context.lam_cr3_mask); -set_tlbstate_lam_mode (mm); -set_bit (MM_CONTEXT_LOCK_LAM , &mm->context.flags); +mm_enable_lam (mm);mmap_write_unlock (mm);
arch/x86/mm/tlb.c +3 -4
@@ -503,9 +503,9 @@ void switch_mm_irqs_off(struct mm_struct *unused, struct mm_struct *next, {struct mm_struct *prev =this_cpu_read (cpu_tlbstate.loaded_mm);u16 prev_asid =this_cpu_read (cpu_tlbstate.loaded_mm_asid); -unsigned long new_lam =mm_lam_cr3_mask (next);bool was_lazy =this_cpu_read (cpu_tlbstate_shared.is_lazy);unsigned cpu =smp_processor_id (); +unsigned long new_lam;u64 next_tlb_gen;bool need_flush;u16 new_asid;
@@ -619,9 +619,7 @@ void switch_mm_irqs_off(struct mm_struct *unused, struct mm_struct *next,cpumask_clear_cpu (cpu,mm_cpumask (prev)); } -/* -* Start remote flushes and then read tlb_gen. -*/ +/* Start receiving IPIs and then read tlb_gen (and LAM below) */ if (next != &init_mm)cpumask_set_cpu (cpu,mm_cpumask (next)); next_tlb_gen =atomic64_read (&next->context.tlb_gen);
@@ -633,6 +631,7 @@ void switch_mm_irqs_off(struct mm_struct *unused, struct mm_struct *next,barrier (); } + new_lam =mm_lam_cr3_mask (next);set_tlbstate_lam_mode (next);if (need_flush) {this_cpu_write (cpu_tlbstate.ctxs[new_asid].ctx_id, next->context.ctx_id);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 144/634 ASoC: rt5682s: Return devm_of_clk_add_hw_provider to transfer the error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
[ Upstream commit 3ff810b9bebe5578a245cfa97c252ab602e703f1 ]
Return devm_of_clk_add_hw_provider() in order to transfer the error, if it fails due to resource allocation failure or device tree clock provider registration failure.
--- sound/soc/codecs/rt5682s.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5682s.c +3 -1
@@ -2828,7 +2828,9 @@ static int rt5682s_register_dai_clks(struct snd_soc_component *component) }if (dev->of_node) { -devm_of_clk_add_hw_provider (dev, of_clk_hw_simple_get, dai_clk_hw); + ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_simple_get, dai_clk_hw); +if (ret) +return ret; }else { ret =devm_clk_hw_register_clkdev (dev, dai_clk_hw, init.name,dev_name (dev));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 145/634 ASoC: tas2781: Use of_property_read_reg()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring (Arm) <[email protected]>
[ Upstream commit 31a45f9190b5b4f5cd8cdec8471babd5215eee04 ]
Replace the open-coded parsing of "reg" with of_property_read_reg(). The #ifdef is also easily replaced with IS_ENABLED().
Stable-dep-of: c2c0b67dca3c ("ASoC: tas2781-i2c: Drop weird GPIO code")
--- sound/soc/codecs/tas2781-i2c.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-)
sound/soc/codecs/tas2781-i2c.c +11 -23
@@ -21,6 +21,7 @@#include <linux/interrupt.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/of_gpio.h> #include <linux/of_irq.h> #include <linux/regmap.h>
@@ -635,33 +636,20 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv) tas_priv->irq_info.irq_gpio =acpi_dev_gpio_irq_get (ACPI_COMPANION (&client->dev),0 ); - }else { + }else if (IS_ENABLED (CONFIG_OF )) {struct device_node *np = tas_priv->dev->of_node; -#ifdef CONFIG_OF -const __be32 *reg, *reg_end; -int len, sw, aw; - - aw =of_n_addr_cells (np); - sw =of_n_size_cells (np); -if (sw ==0 ) { - reg = (const __be32 *)of_get_property (np, -"reg" , &len); - reg_end = reg + len/sizeof (*reg); - ndev =0 ; -do { - dev_addrs[ndev] =of_read_number (reg, aw); - reg += aw; - ndev++; - }while (reg < reg_end); - }else { - ndev =1 ; - dev_addrs[0 ] = client->addr; +u64 addr; + +for (i =0 ; i <TASDEVICE_MAX_CHANNELS ; i++) { +if (of_property_read_reg (np, i, &addr,NULL )) +break ; + dev_addrs[ndev++] = addr; } -#else + + tas_priv->irq_info.irq_gpio =of_irq_get (np,0 ); + }else { ndev =1 ; dev_addrs[0 ] = client->addr; -#endif - tas_priv->irq_info.irq_gpio =of_irq_get (np,0 ); } tas_priv->ndev = ndev;for (i =0 ; i < ndev; i++)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 146/634 ASoC: tas2781-i2c: Drop weird GPIO code
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c2c0b67dca3cb3b3cea0dd60075a1c5ba77e2fcd ]
The tas2781-i2c driver gets an IRQ from either ACPI or device tree, then proceeds to check if the IRQ has a corresponding GPIO and in case it does enforce the GPIO as input and set a label on it.
This is abuse of the API:
- First we cannot guarantee that the numberspaces of the GPIOs and the IRQs are the same, i.e that an IRQ number corresponds to a GPIO number like that.
- Second, GPIO chips and IRQ chips should be treated as orthogonal APIs, the irqchip needs to ascertain that the backing GPIO line is set to input etc just using the irqchip.
- Third it is using the legacy <linux/gpio.h> API which should not be used in new code yet this was added just a year ago.
Delete the offending code.
If this creates problems the GPIO and irqchip maintainers can help to fix the issues.
It *should* not create any problems, because the irq isn't used anywhere in the driver, it's just obtained and then left unused.
--- include/sound/tas2781.h | 7 +------ sound/pci/hda/tas2781_hda_i2c.c | 2 +- sound/soc/codecs/tas2781-comlib.c | 3 --- sound/soc/codecs/tas2781-fmwlib.c | 1 - sound/soc/codecs/tas2781-i2c.c | 24 +++--------------------- 5 files changed, 5 insertions(+), 32 deletions(-)
include/sound/tas2781.h +1 -6
@@ -80,11 +80,6 @@ struct tasdevice {bool is_loaderr; }; -struct tasdevice_irqinfo { -int irq_gpio; -int irq; -}; -struct calidata {unsigned char *data;unsigned long total_sz;
@@ -92,7 +87,6 @@ struct calidata {struct tasdevice_priv {struct tasdevice tasdevice[TASDEVICE_MAX_CHANNELS ]; -struct tasdevice_irqinfo irq_info;struct tasdevice_rca rcabin;struct calidata cali_data;struct tasdevice_fw *fmw;
@@ -113,6 +107,7 @@ struct tasdevice_priv {unsigned int chip_id;unsigned int sysclk; +int irq;int cur_prog;int cur_conf;int fw_state;
sound/pci/hda/tas2781_hda_i2c.c +1 -1
@@ -822,7 +822,7 @@ static int tas2781_hda_i2c_probe(struct i2c_client *clt) }else return -ENODEV ; - tas_hda->priv->irq_info.irq = clt->irq; + tas_hda->priv->irq = clt->irq; ret =tas2781_read_acpi (tas_hda->priv, device_name);if (ret) return dev_err_probe(tas_hda->dev, ret,
sound/soc/codecs/tas2781-comlib.c +0 -3
@@ -14,7 +14,6 @@#include <linux/interrupt.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/of_irq.h> #include <linux/regmap.h> #include <linux/slab.h>
@@ -406,8 +405,6 @@ EXPORT_SYMBOL_GPL(tasdevice_dsp_remove);void tasdevice_remove (struct tasdevice_priv *tas_priv) { -if (gpio_is_valid (tas_priv->irq_info.irq_gpio)) -gpio_free (tas_priv->irq_info.irq_gpio);mutex_destroy (&tas_priv->codec_lock); }EXPORT_SYMBOL_GPL (tasdevice_remove);
sound/soc/codecs/tas2781-fmwlib.c +0 -1
@@ -13,7 +13,6 @@#include <linux/interrupt.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/of_irq.h> #include <linux/regmap.h> #include <linux/slab.h>
sound/soc/codecs/tas2781-i2c.c +3 -21
@@ -22,7 +22,6 @@#include <linux/module.h> #include <linux/of.h> #include <linux/of_address.h> -#include <linux/of_gpio.h> #include <linux/of_irq.h> #include <linux/regmap.h> #include <linux/slab.h>
@@ -619,7 +618,7 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv) {struct i2c_client *client = (struct i2c_client *)tas_priv->client;unsigned int dev_addrs[TASDEVICE_MAX_CHANNELS ]; -int rc, i, ndev =0 ; +int i, ndev =0 ;if (tas_priv->isacpi) { ndev = device_property_read_u32_array(&client->dev,
@@ -634,7 +633,7 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv) "ti,audio-slots", dev_addrs, ndev); } - tas_priv->irq_info.irq_gpio = + tas_priv->irq =acpi_dev_gpio_irq_get (ACPI_COMPANION (&client->dev),0 ); }else if (IS_ENABLED (CONFIG_OF )) {struct device_node *np = tas_priv->dev->of_node;
@@ -646,7 +645,7 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv) dev_addrs[ndev++] = addr; } - tas_priv->irq_info.irq_gpio =of_irq_get (np,0 ); + tas_priv->irq =of_irq_get (np,0 ); }else { ndev =1 ; dev_addrs[0 ] = client->addr;
@@ -662,23 +661,6 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv) __func__);strcpy (tas_priv->dev_name, tasdevice_id[tas_priv->chip_id].name); - -if (gpio_is_valid (tas_priv->irq_info.irq_gpio)) { - rc =gpio_request (tas_priv->irq_info.irq_gpio, -"AUDEV-IRQ" ); -if (!rc) { -gpio_direction_input ( - tas_priv->irq_info.irq_gpio); - - tas_priv->irq_info.irq = -gpio_to_irq (tas_priv->irq_info.irq_gpio); - }else -dev_err (tas_priv->dev,"%s: GPIO %d request error\n" , - __func__, tas_priv->irq_info.irq_gpio); - }else -dev_err (tas_priv->dev, -"Looking up irq-gpio property failed %d\n" , - tas_priv->irq_info.irq_gpio); }static int tasdevice_i2c_probe (struct i2c_client *i2c)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 147/634 ASoC: tas2781-i2c: Get the right GPIO line
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 1c4b509edad15192bfb64c81d3c305bbae8070db ]
The code is obtaining a GPIO reset using the reset GPIO name "reset-gpios", but the gpiolib is already adding the suffix "-gpios" to anything passed to this function and will be looking for "reset-gpios-gpios" which is most certainly not what the author desired.
Fix it up.
--- sound/soc/codecs/tas2781-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tas2781-i2c.c +1 -1
@@ -655,7 +655,7 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv) tas_priv->tasdevice[i].dev_addr = dev_addrs[i]; tas_priv->reset =devm_gpiod_get_optional (&client->dev, -"reset-gpios" ,GPIOD_OUT_HIGH ); +"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (tas_priv->reset))dev_err (tas_priv->dev,"%s Can't get reset GPIO\n" , __func__);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 148/634 selftests/ftrace: Add required dependency for kprobe tests
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 41f37c852ac3fbfd072a00281b60dc7ba056be8c ]
kprobe_args_{char,string}.tc are using available_filter_functions file which is provided by function tracer. Thus if function tracer is disabled, these tests are failed on recent kernels because tracefs_create_dir is not raised events by adding a dynamic event.
Add available_filter_functions to requires line.
--- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc | 2 +- .../selftests/ftrace/test.d/kprobe/kprobe_args_string.tc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc +1 -1
@@ -1,7 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # description: Kprobe event char type argument -# requires: kprobe_events +# requires: kprobe_events available_filter_functions case `uname -m` in x86_64)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc +1 -1
@@ -1,7 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # description: Kprobe event string type argument -# requires: kprobe_events +# requires: kprobe_events available_filter_functions case `uname -m` in x86_64)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 149/634 ALSA: hda: cs35l41: fix module autoloading
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuntao Liu <[email protected]>
[ Upstream commit 48f1434a4632c7da1a6a94e159512ebddbe13392 ]
Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from spi_device_id table.
--- sound/pci/hda/cs35l41_hda_spi.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/cs35l41_hda_spi.c +1 -0
@@ -38,6 +38,7 @@ static const struct spi_device_id cs35l41_hda_spi_id[] = { { "cs35l41-hda", 0 }, {} }; +MODULE_DEVICE_TABLE (spi, cs35l41_hda_spi_id);static const struct acpi_device_id cs35l41_acpi_hda_match[] = { { "CSC3551", 0 },
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 150/634 selftests/ftrace: Fix test to handle both old and new kernels
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit c049acee3c71cfc26c739f82617a84e13e471a45 ]
The function "scheduler_tick" was renamed to "sched_tick" and a selftest that used that function for testing function trace filtering used that function as part of the test.
But the change causes it to fail when run on older kernels. As tests should not fail on older kernels, add a check to see which name is available before testing.
--- .../ftrace/test.d/ftrace/func_set_ftrace_file.tc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc +8 -1
@@ -19,7 +19,14 @@ fail() { # mesg FILTER=set_ftrace_filter FUNC1="schedule" -FUNC2="sched_tick" +if grep '^sched_tick\b' available_filter_functions; then + FUNC2="sched_tick" +elif grep '^scheduler_tick\b' available_filter_functions; then + FUNC2="scheduler_tick" +else + exit_unresolved +fi + ALL_FUNCS="#### all functions enabled ####"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 151/634 x86/boot/64: Strip percpu address space when setting up GDT descriptors
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uros Bizjak <[email protected]>
[ Upstream commit b51207dc02ec3aeaa849e419f79055d7334845b6 ]
init_per_cpu_var() returns a pointer in the percpu address space while rip_rel_ptr() expects a pointer in the generic address space.
When strict address space checks are enabled, GCC's named address space checks fail:
asm.h:124:63: error: passing argument 1 of 'rip_rel_ptr' from
pointer to non-enclosed address space
Add a explicit cast to remove address space of the returned pointer.
--- arch/x86/kernel/head64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/head64.c +2 -1
@@ -559,10 +559,11 @@ void early_setup_idt(void)*/ void __head startup_64_setup_gdt_idt(void) { +struct desc_struct *gdt = (void *)(__force unsigned long )init_per_cpu_var (gdt_page.gdt);void *handler =NULL ;struct desc_ptr startup_gdt_descr = { - .address = (unsigned long )&RIP_REL_REF (init_per_cpu_var (gdt_page.gdt)), + .address = (unsigned long )&RIP_REL_REF (*gdt), .size =GDT_SIZE -1 , };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 152/634 m68k: Fix kernel_clone_args.flags in m68k_clone()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
[ Upstream commit 09b3d870faa7bc3e96c0978ab3cf4e96e4b15571 ]
Stan Johnson recently reported a failure from the 'dump' command:
DUMP: Date of this level 0 dump: Fri Aug 9 23:37:15 2024
DUMP: Dumping /dev/sda (an unlisted file system) to /dev/null
DUMP: Label: none
DUMP: Writing 10 Kilobyte records
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 3595695 blocks.
DUMP: Context save fork fails in parent 671
The dump program uses the clone syscall with the CLONE_IO flag, that is, flags == 0x80000000. When that value is promoted from long int to u64 by m68k_clone(), it undergoes sign-extension. The new value includes CLONE_INTO_CGROUP so the validation in cgroup_css_set_fork() fails and the syscall returns -EBADF. Avoid sign-extension by casting to u32.
--- arch/m68k/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/process.c +1 -1
@@ -117,7 +117,7 @@ asmlinkage int m68k_clone(struct pt_regs *regs) {/* regs will be equal to current_pt_regs() */ struct kernel_clone_args args = { - .flags = regs->d1 & ~CSIGNAL , + .flags = (u32)(regs->d1) & ~CSIGNAL , .pidfd = (int __user *)regs->d3, .child_tid = (int __user *)regs->d4, .parent_tid = (int __user *)regs->d3,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 153/634 ASoC: loongson: fix error release
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: tangbin <[email protected]>
[ Upstream commit 97688a9c5b1fd2b826c682cdfa36d411a5c99828 ]
In function loongson_card_parse_of(), when get device_node 'codec' failed, the function of_node_put(codec) should not be invoked, thus fix error release.
--- sound/soc/loongson/loongson_card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/loongson/loongson_card.c +2 -2
@@ -127,8 +127,8 @@ static int loongson_card_parse_of(struct loongson_card_data *data) codec =of_get_child_by_name (dev->of_node,"codec" );if (!codec) {dev_err (dev,"audio-codec property missing or invalid\n" ); - ret = -EINVAL ; - goto err; +of_node_put (cpu); +return -EINVAL ; }for (i =0 ; i < card->num_links; i++) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 154/634 selftests/ftrace: Fix eventfs ownership testcase to find mount point
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit f0a6ecebd858658df213d114b0530f8f0b96e396 ]
Fix eventfs ownership testcase to find mount point if stat -c "%m" failed. This can happen on the system based on busybox. In this case, this will try to use the current working directory, which should be a tracefs top directory (and eventfs is mounted as a part of tracefs.)
If it does not work, the test is skipped as UNRESOLVED because of the environmental problem.
--- .../ftrace/test.d/00basic/test_ownership.tc | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc +12 -0
@@ -6,6 +6,18 @@ original_group=`stat -c "%g" .` original_owner=`stat -c "%u" .` mount_point=`stat -c '%m' .` + +# If stat -c '%m' does not work (e.g. busybox) or failed, try to use the +# current working directory (which should be a tracefs) as the mount point. +if [ ! -d "$mount_point" ]; then + if mount | grep -qw $PWD ; then + mount_point=$PWD + else + # If PWD doesn't work, that is an environmental problem. + exit_unresolved + fi +fi + mount_options=`mount | grep "$mount_point" | sed -e 's/.*(\(.*\)).*/\1/'` # find another owner and group that is not the original
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 155/634 selftests:resctrl: Fix build failure on archs without __cpuid_count()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan <[email protected]>
[ Upstream commit 7beaf1da074f7ea25454d6c11da142c3892d3c4e ]
When resctrl is built on architectures without __cpuid_count() support, build fails. resctrl uses __cpuid_count() defined in kselftest.h.
Even though the problem is seen while building resctrl on aarch64, this error can be seen on any platform that doesn't support CPUID.
CPUID is a x86/x86-64 feature and code paths with CPUID asm commands will fail to build on all other architectures.
All others tests call __cpuid_count() do so from x86/x86_64 code paths when _i386__ or __x86_64__ are defined. resctrl is an exception.
Fix the problem by defining __cpuid_count() only when __i386__ or __x86_64__ are defined in kselftest.h and changing resctrl to call __cpuid_count() only when __i386__ or __x86_64__ are defined.
In file included from resctrl.h:24,
from cat_test.c:11:
In function ‘arch_supports_noncont_cat’,
inlined from ‘noncont_cat_run_test’ at cat_test.c:326:6:
../kselftest.h:74:9: error: impossible constraint in ‘asm’
74 | __asm__ __volatile__ ("cpuid\n\t" \
| ^~~~~~~
cat_test.c:304:17: note: in expansion of macro ‘__cpuid_count’
304 | __cpuid_count(0x10, 1, eax, ebx, ecx, edx);
| ^~~~~~~~~~~~~
../kselftest.h:74:9: error: impossible constraint in ‘asm’
74 | __asm__ __volatile__ ("cpuid\n\t" \
| ^~~~~~~cat_test.c:306:17: note: in expansion of macro ‘__cpuid_count’
306 | __cpuid_count(0x10, 2, eax, ebx, ecx, edx);
--- tools/testing/selftests/kselftest.h | 2 ++ tools/testing/selftests/resctrl/cat_test.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
tools/testing/selftests/kselftest.h +2 -0
@@ -61,6 +61,7 @@#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0]))#endif +#if defined(__i386__) || defined(__x86_64__)/* arch */ /* * gcc cpuid.h provides __cpuid_count() since v4.4. * Clang/LLVM cpuid.h provides __cpuid_count() since v3.4.0.
@@ -75,6 +76,7 @@ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level), "2" (count))#endif +#endif /* end arch */ /* define kselftest exit codes */ #define KSFT_PASS 0
tools/testing/selftests/resctrl/cat_test.c +5 -2
@@ -293,12 +293,12 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_paramstatic bool arch_supports_noncont_cat (const struct resctrl_test *test) { -unsigned int eax, ebx, ecx, edx; -/* AMD always supports non-contiguous CBM. */ if (get_vendor () ==ARCH_AMD )return true; +#if defined(__i386__) || defined(__x86_64__)/* arch */ +unsigned int eax, ebx, ecx, edx;/* Intel support for non-contiguous CBM needs to be discovered. */ if (!strcmp (test->resource,"L3" ))__cpuid_count (0x10 ,1 , eax, ebx, ecx, edx);
@@ -308,6 +308,9 @@ static bool arch_supports_noncont_cat(const struct resctrl_test *test)return false;return ((ecx >>3 ) &1 ); +#endif /* end arch */ + +return false; } static int noncont_cat_run_test(const struct resctrl_test *test,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 156/634 hwmon: (max16065) Fix overflows seen when writing limits
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 744ec4477b11c42e2c8de9eb8364675ae7a0bd81 ]
Writing large limits resulted in overflows as reported by module tests.
in0_lcrit: Suspected overflow: [max=5538, read 0, written 2147483647]in0_crit: Suspected overflow: [max=5538, read 0, written 2147483647]in0_min: Suspected overflow: [max=5538, read 0, written 2147483647]
Fix the problem by clamping prior to multiplications and the use of DIV_ROUND_CLOSEST, and by using consistent variable types.
--- drivers/hwmon/max16065.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hwmon/max16065.c +3 -2
@@ -114,9 +114,10 @@ static inline int LIMIT_TO_MV(int limit, int range)return limit * range /256 ; } -static inline int MV_TO_LIMIT (int mv,int range) +static inline int MV_TO_LIMIT (unsigned long mv,int range) { -return clamp_val (DIV_ROUND_CLOSEST (mv *256 , range),0 ,255 ); + mv =clamp_val (mv,0 ,ULONG_MAX /256 ); +return DIV_ROUND_CLOSEST (clamp_val (mv *256 ,0 , range *255 ), range); }static inline int ADC_TO_CURR (int adc,int gain)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 157/634 hwmon: (max16065) Remove use of i2c_match_id()
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 5a71654b398e3471f0169c266a3587cf09e1200c ]
The function i2c_match_id() is used to fetch the matching ID from the i2c_device_id table. This is often used to then retrieve the matching driver_data. This can be done in one step with the helper i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need to have that forward declared, allowing us to remove those or move the i2c_device_id table down to its more natural spot with the other module info.
* It also checks for device match data, which allows for OF and ACPI based probing. That means we do not have to manually check those first and can remove those checks.
Stable-dep-of: 119abf7d1815 ("hwmon: (max16065) Fix alarm attributes")
--- drivers/hwmon/max16065.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/hwmon/max16065.c +4 -6
@@ -494,8 +494,6 @@ static const struct attribute_group max16065_max_group = { .is_visible = max16065_secondary_is_visible, }; -static const struct i2c_device_id max16065_id[]; -static int max16065_probe (struct i2c_client *client) {struct i2c_adapter *adapter = client->adapter;
@@ -506,7 +504,7 @@ static int max16065_probe(struct i2c_client *client)bool have_secondary;/* true if chip has secondary limits */ bool secondary_is_max = false;/* secondary limits reflect max */ int groups =0 ; -const struct i2c_device_id *id =i2c_match_id (max16065_id, client); +enum chips chip = (uintptr_t )i2c_get_match_data (client);if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_READ_WORD_DATA ))
@@ -519,9 +517,9 @@ static int max16065_probe(struct i2c_client *client) data->client = client;mutex_init (&data->update_lock); - data->num_adc = max16065_num_adc[id->driver_data]; - data->have_current = max16065_have_current[id->driver_data]; - have_secondary = max16065_have_secondary[id->driver_data]; + data->num_adc = max16065_num_adc[chip]; + data->have_current = max16065_have_current[chip]; + have_secondary = max16065_have_secondary[chip];if (have_secondary) { val =i2c_smbus_read_byte_data (client,MAX16065_SW_ENABLE );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 158/634 hwmon: (max16065) Fix alarm attributes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 119abf7d1815f098f7f91ae7abc84324a19943d7 ]
Chips reporting overcurrent alarms report it in the second alarm register. That means the second alarm register has to be read, even if the chip only supports 8 or fewer ADC channels.
MAX16067 and MAX16068 report undervoltage and overvoltage alarms in separate registers. Fold register contents together to report both with the existing alarm attribute. This requires actually storing the chip type in struct max16065_data. Rename the variable 'chip' to match the variable name used in the probe function.
--- drivers/hwmon/max16065.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/hwmon/max16065.c +10 -2
@@ -79,7 +79,7 @@ static const bool max16065_have_current[] = { };struct max16065_data { -enum chips type; +enum chips chip;struct i2c_client *client;const struct attribute_group *groups[4 ];struct mutex update_lock;
@@ -162,10 +162,17 @@ static struct max16065_data *max16065_update_device(struct device *dev) MAX16065_CURR_SENSE); } -for (i =0 ; i <DIV_ROUND_UP (data->num_adc,8 ); i++) +for (i =0 ; i <2 ; i++) data->fault[i] =i2c_smbus_read_byte_data (client,MAX16065_FAULT (i)); +/* +* MAX16067 and MAX16068 have separate undervoltage and +* overvoltage alarm bits. Squash them together. +*/ +if (data->chip == max16067 || data->chip == max16068) + data->fault[0 ] |= data->fault[1 ]; + data->last_updated = jiffies; data->valid = true; }
@@ -514,6 +521,7 @@ static int max16065_probe(struct i2c_client *client)if (unlikely (!data))return -ENOMEM ; + data->chip = chip; data->client = client;mutex_init (&data->update_lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 159/634 mtd: slram: insert break after errors in parsing the map
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mirsad Todorovac <[email protected]>
[ Upstream commit 336c218dd7f0588ed8a7345f367975a00a4f003f ]
GCC 12.3.0 compiler on linux-next next-20240709 tree found the execution path in which, due to lazy evaluation, devlength isn't initialised with the parsed string:
289 while (map) {
290 devname = devstart = devlength = NULL;
291
292 if (!(devname = strsep(&map, ","))) {
293 E("slram: No devicename specified.\n");
294 break;
295 }
296 T("slram: devname = %s\n", devname);
297 if ((!map) || (!(devstart = strsep(&map, ",")))) {
298 E("slram: No devicestart specified.\n");
299 }
300 T("slram: devstart = %s\n", devstart);
→ 301 if ((!map) || (!(devlength = strsep(&map, ",")))) {
302 E("slram: No devicelength / -end specified.\n");
303 }
→ 304 T("slram: devlength = %s\n", devlength);
305 if (parse_cmdline(devname, devstart, devlength) != 0) {
306 return(-EINVAL);
307 }
Parsing should be finished after map == NULL, so a break is best inserted after each E("slram: ... \n") error message.
--- drivers/mtd/devices/slram.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/devices/slram.c +2 -0
@@ -296,10 +296,12 @@ static int __init init_slram(void)T ("slram: devname = %s\n" , devname);if ((!map) || (!(devstart =strsep (&map,"," )))) {E ("slram: No devicestart specified.\n" ); +break ; }T ("slram: devstart = %s\n" , devstart);if ((!map) || (!(devlength =strsep (&map,"," )))) {E ("slram: No devicelength / -end specified.\n" ); +break ; }T ("slram: devlength = %s\n" , devlength);if (parse_cmdline (devname, devstart, devlength) !=0 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 160/634 hwmon: (ntc_thermistor) fix module autoloading
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuntao Liu <[email protected]>
[ Upstream commit b6964d66a07a9003868e428a956949e17ab44d7e ]
Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from of_device_id table.
Message-ID: <[email protected]>
--- drivers/hwmon/ntc_thermistor.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/ntc_thermistor.c +1 -0
@@ -62,6 +62,7 @@ static const struct platform_device_id ntc_thermistor_id[] = { [NTC_SSG1404001221] = { "ssg1404_001221", TYPE_NCPXXWB473 }, [NTC_LAST ] = { }, }; +MODULE_DEVICE_TABLE (platform ,ntc_thermistor_id );/* * A compensation table should be sorted by the values of .ohm
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 161/634 power: supply: axp20x_battery: Remove design from min and max voltage
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Morgan <[email protected]>
[ Upstream commit 61978807b00f8a1817b0e5580981af1cd2f428a5 ]
The POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN and POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN values should be immutable properties of the battery, but for this driver they are writable values and used as the minimum and maximum values for charging. Remove the DESIGN designation from these values.
--- drivers/power/supply/axp20x_battery.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/power/supply/axp20x_battery.c +8 -8
@@ -303,11 +303,11 @@ static int axp20x_battery_get_prop(struct power_supply *psy, val->intval = reg &AXP209_FG_PERCENT ;break ; -case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MAX :return axp20x_batt->data->get_max_voltage (axp20x_batt, &val->intval); -case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MIN : ret =regmap_read (axp20x_batt->regmap,AXP20X_V_OFF , ®);if (ret)return ret;
@@ -455,10 +455,10 @@ static int axp20x_battery_set_prop(struct power_supply *psy,struct axp20x_batt_ps *axp20x_batt =power_supply_get_drvdata (psy);switch (psp) { -case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MIN :return axp20x_set_voltage_min_design (axp20x_batt, val->intval); -case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN : +case POWER_SUPPLY_PROP_VOLTAGE_MAX :return axp20x_batt->data->set_max_voltage (axp20x_batt, val->intval);case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT :
@@ -493,8 +493,8 @@ static enum power_supply_property axp20x_battery_props[] = {POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT ,POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX ,POWER_SUPPLY_PROP_HEALTH , -POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN , -POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN , +POWER_SUPPLY_PROP_VOLTAGE_MAX , +POWER_SUPPLY_PROP_VOLTAGE_MIN , POWER_SUPPLY_PROP_CAPACITY, };
@@ -502,8 +502,8 @@ static int axp20x_battery_prop_writeable(struct power_supply *psy, enum power_supply_property psp) {return psp ==POWER_SUPPLY_PROP_STATUS || - psp ==POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN || - psp ==POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN || + psp ==POWER_SUPPLY_PROP_VOLTAGE_MIN || + psp ==POWER_SUPPLY_PROP_VOLTAGE_MAX || psp ==POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT || psp ==POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 162/634 power: supply: max17042_battery: Fix SOC threshold calc w/ no current sense
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artur Weber <[email protected]>
[ Upstream commit 3a3acf839b2cedf092bdd1ff65b0e9895df1656b ]
Commit 223a3b82834f ("power: supply: max17042_battery: use VFSOC for capacity when no rsns") made it so that capacity on systems without current sensing would be read from VFSOC instead of RepSOC. However, the SOC threshold calculation still read RepSOC to get the SOC regardless of the current sensing option state.
Fix this by applying the same conditional to determine which register should be read.
This also seems to be the intended behavior as per the datasheet - SOC alert config value in MiscCFG on setups without current sensing is set to a value of 0b11, indicating SOC alerts being generated based on VFSOC, instead of 0b00 which indicates SOC alerts being generated based on RepSOC.
This fixes an issue on the Galaxy S3/Midas boards, where the alert interrupt would be constantly retriggered, causing high CPU usage on idle (around ~12%-15%).
--- drivers/power/supply/max17042_battery.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/power/supply/max17042_battery.c +4 -1
@@ -853,7 +853,10 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off)/* program interrupt thresholds such that we should * get interrupt for every 'off' perc change in the soc */ -regmap_read (map, MAX17042_RepSOC, &soc); +if (chip->pdata->enable_current_sense) +regmap_read (map, MAX17042_RepSOC, &soc); +else +regmap_read (map,MAX17042_VFSOC , &soc); soc >>=8 ; soc_tr = (soc + off) <<8 ;if (off < soc)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 163/634 fbdev: hpfb: Fix an error handling path in hpfb_dio_probe()
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 aa578e897520f32ae12bec487f2474357d01ca9c ]
If an error occurs after request_mem_region(), a corresponding release_mem_region() should be called, as already done in the remove function.
--- drivers/video/fbdev/hpfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/hpfb.c +1 -0
@@ -345,6 +345,7 @@ static int hpfb_dio_probe(struct dio_dev *d, const struct dio_device_id *ent)if (hpfb_init_one (paddr, vaddr)) {if (d->scode >=DIOII_SCBASE )iounmap ((void *)vaddr); +release_mem_region (d->resource.start,resource_size (&d->resource));return -ENOMEM ; }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 164/634 iommu/amd: Handle error path in amd_iommu_probe_device()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasant Hegde <[email protected]>
[ Upstream commit 293aa9ec694e633bff83ab93715a2684e15fe214 ]
Do not try to set max_pasids in error path as dev_data is not allocated.
--- drivers/iommu/amd/iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iommu/amd/iommu.c +5 -3
@@ -2185,11 +2185,12 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)dev_err (dev,"Failed to initialize - trying to proceed anyway\n" ); iommu_dev =ERR_PTR (ret);iommu_ignore_device (iommu, dev); - }else { -amd_iommu_set_pci_msi_domain (dev, iommu); - iommu_dev = &iommu->iommu; + goto out_err; } +amd_iommu_set_pci_msi_domain (dev, iommu); + iommu_dev = &iommu->iommu; +/* * If IOMMU and device supports PASID then it will contain max * supported PASIDs, else it will be zero.
@@ -2201,6 +2202,7 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev) pci_max_pasids(to_pci_dev(dev))); } +out_err:iommu_completion_wait (iommu);return iommu_dev;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 165/634 iommu/amd: Allocate the page table root using GFP_KERNEL
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit b0a6c883bcd42eeb0850135e529b34b64d57673c ]
Domain allocation is always done under a sleepable context, the v1 path and other drivers use GFP_KERNEL already. Fix the v2 path to also use GFP_KERNEL.
--- drivers/iommu/amd/io_pgtable_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/io_pgtable_v2.c +1 -1
@@ -362,7 +362,7 @@ static struct io_pgtable *v2_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coostruct protection_domain *pdom = (struct protection_domain *)cookie;int ias =IOMMU_IN_ADDR_BIT_SIZE ; - pgtable->pgd =iommu_alloc_page_node (pdom->nid,GFP_ATOMIC ); + pgtable->pgd =iommu_alloc_page_node (pdom->nid,GFP_KERNEL );if (!pgtable->pgd)return NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 166/634 iommu/amd: Convert comma to semicolon
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit 86c5eac3c4c4a2ee124d202af9a141bd0457ee68 ]
Replace a comma between expression statements by a semicolon.
Stable-dep-of: 7a41dcb52f9d ("iommu/amd: Set the pgsize_bitmap correctly")
--- drivers/iommu/amd/io_pgtable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/amd/io_pgtable.c +3 -3
@@ -588,9 +588,9 @@ static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo {struct amd_io_pgtable *pgtable =io_pgtable_cfg_to_data (cfg); - cfg->pgsize_bitmap =AMD_IOMMU_PGSIZES , - cfg->ias =IOMMU_IN_ADDR_BIT_SIZE , - cfg->oas =IOMMU_OUT_ADDR_BIT_SIZE , + cfg->pgsize_bitmap =AMD_IOMMU_PGSIZES ; + cfg->ias =IOMMU_IN_ADDR_BIT_SIZE ; + cfg->oas =IOMMU_OUT_ADDR_BIT_SIZE ; cfg->tlb = &v1_flush_ops; pgtable->iop.ops.map_pages = iommu_v1_map_pages;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 167/634 iommu/amd: Move allocation of the top table into v1_alloc_pgtable
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 8d00b77a52ef4b2091696ca25753d0ab95e4d839 ]
All the page table memory should be allocated/free within the io_pgtable struct. The v2 path is already doing this, make it consistent.
It is hard to see but the free of the root in protection_domain_free() is a NOP on the success path because v1_free_pgtable() does amd_iommu_domain_clr_pt_root().
The root memory is already freed because free_sub_pt() put it on the freelist. The free path in protection_domain_free() is only used during error unwind of protection_domain_alloc().
Stable-dep-of: 7a41dcb52f9d ("iommu/amd: Set the pgsize_bitmap correctly")
--- drivers/iommu/amd/io_pgtable.c | 8 ++++++-- drivers/iommu/amd/iommu.c | 21 ++------------------- 2 files changed, 8 insertions(+), 21 deletions(-)
drivers/iommu/amd/io_pgtable.c +6 -2
@@ -574,20 +574,24 @@ static void v1_free_pgtable(struct io_pgtable *iop) pgtable->mode > PAGE_MODE_6_LEVEL);free_sub_pt (pgtable->root, pgtable->mode, &freelist); +iommu_put_pages_list (&freelist);/* Update data structure */ amd_iommu_domain_clr_pt_root (dom);/* Make changes visible to IOMMUs */ amd_iommu_domain_update (dom); - -iommu_put_pages_list (&freelist); }static struct io_pgtable *v1_alloc_pgtable (struct io_pgtable_cfg *cfg,void *cookie) {struct amd_io_pgtable *pgtable =io_pgtable_cfg_to_data (cfg); + pgtable->root =iommu_alloc_page (GFP_KERNEL ); +if (!pgtable->root) +return NULL ; + pgtable->mode =PAGE_MODE_3_LEVEL ; + cfg->pgsize_bitmap =AMD_IOMMU_PGSIZES ; cfg->ias =IOMMU_IN_ADDR_BIT_SIZE ; cfg->oas =IOMMU_OUT_ADDR_BIT_SIZE ;
drivers/iommu/amd/iommu.c +2 -19
@@ -52,8 +52,6 @@#define HT_RANGE_START (0xfd00000000ULL)#define HT_RANGE_END (0xffffffffffULL) -#define DEFAULT_PGTABLE_LEVEL PAGE_MODE_3_LEVEL -static DEFINE_SPINLOCK (pd_bitmap_lock);LIST_HEAD (ioapic_map);
@@ -2267,30 +2265,15 @@ void protection_domain_free(struct protection_domain *domain)if (domain->iop.pgtbl_cfg.tlb)free_io_pgtable_ops (&domain->iop.iop.ops); -if (domain->iop.root) -iommu_free_page (domain->iop.root); -if (domain->id)domain_id_free (domain->id);kfree (domain); } -static int protection_domain_init_v1 (struct protection_domain *domain,int mode) +static int protection_domain_init_v1 (struct protection_domain *domain) { -u64 *pt_root =NULL ; - -BUG_ON (mode <PAGE_MODE_NONE || mode >PAGE_MODE_6_LEVEL ); - -if (mode !=PAGE_MODE_NONE ) { - pt_root =iommu_alloc_page (GFP_KERNEL ); -if (!pt_root) -return -ENOMEM ; - } - domain->pd_mode =PD_MODE_V1 ; -amd_iommu_domain_set_pgtable (domain, pt_root, mode); -return 0 ; }
@@ -2343,7 +2326,7 @@ struct protection_domain *protection_domain_alloc(unsigned int type)switch (pgtable) {case AMD_IOMMU_V1 : - ret =protection_domain_init_v1 (domain,DEFAULT_PGTABLE_LEVEL ); + ret =protection_domain_init_v1 (domain);break ;case AMD_IOMMU_V2 : ret =protection_domain_init_v2 (domain);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 168/634 iommu/amd: Set the pgsize_bitmap correctly
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 7a41dcb52f9de6079621fc31c3b84c7fc290934b ]
When using io_pgtable the correct pgsize_bitmap is stored in the cfg, both v1_alloc_pgtable() and v2_alloc_pgtable() set it correctly.
This fixes a bug where the v2 pgtable had the wrong pgsize as protection_domain_init_v2() would set it and then do_iommu_domain_alloc() immediately resets it.
Remove the confusing ops.pgsize_bitmap since that is not used if the driver sets domain.pgsize_bitmap.
--- drivers/iommu/amd/iommu.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-)
drivers/iommu/amd/iommu.c +4 -24
@@ -2271,26 +2271,11 @@ void protection_domain_free(struct protection_domain *domain)kfree (domain); } -static int protection_domain_init_v1 (struct protection_domain *domain) -{ - domain->pd_mode =PD_MODE_V1 ; -return 0 ; -} - -static int protection_domain_init_v2 (struct protection_domain *pdom) -{ - pdom->pd_mode =PD_MODE_V2 ; - pdom->domain.pgsize_bitmap =AMD_IOMMU_PGSIZES_V2 ; - -return 0 ; -} -struct protection_domain *protection_domain_alloc (unsigned int type) {struct io_pgtable_ops *pgtbl_ops;struct protection_domain *domain;int pgtable; -int ret; domain =kzalloc (sizeof (*domain),GFP_KERNEL );if (!domain)
@@ -2326,18 +2311,14 @@ struct protection_domain *protection_domain_alloc(unsigned int type)switch (pgtable) {case AMD_IOMMU_V1 : - ret =protection_domain_init_v1 (domain); + domain->pd_mode =PD_MODE_V1 ;break ;case AMD_IOMMU_V2 : - ret =protection_domain_init_v2 (domain); + domain->pd_mode =PD_MODE_V2 ;break ;default : - ret = -EINVAL ; -break ; - } - -if (ret) goto out_err; + } pgtbl_ops =alloc_io_pgtable_ops (pgtable, &domain->iop.pgtbl_cfg, domain);if (!pgtbl_ops)
@@ -2390,10 +2371,10 @@ static struct iommu_domain *do_iommu_domain_alloc(unsigned int type, domain->domain.geometry.aperture_start =0 ; domain->domain.geometry.aperture_end =dma_max_address (); domain->domain.geometry.force_aperture = true; + domain->domain.pgsize_bitmap = domain->iop.iop.cfg.pgsize_bitmap;if (iommu) { domain->domain.type = type; - domain->domain.pgsize_bitmap = iommu->iommu.ops->pgsize_bitmap; domain->domain.ops = iommu->iommu.ops->default_domain_ops;if (dirty_tracking)
@@ -2852,7 +2833,6 @@ const struct iommu_ops amd_iommu_ops = { .device_group = amd_iommu_device_group, .get_resv_regions = amd_iommu_get_resv_regions, .is_attach_deferred = amd_iommu_is_attach_deferred, - .pgsize_bitmap = AMD_IOMMU_PGSIZES, .def_domain_type = amd_iommu_def_domain_type, .dev_enable_feat = amd_iommu_dev_enable_feature, .dev_disable_feat = amd_iommu_dev_disable_feature,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 169/634 iommu/amd: Do not set the D bit on AMD v2 table entries
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 2910a7fa1be090fc7637cef0b2e70bcd15bf5469 ]
The manual says that bit 6 is IGN for all Page-Table Base Address pointers, don't set it.
--- drivers/iommu/amd/io_pgtable_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/io_pgtable_v2.c +1 -1
@@ -51,7 +51,7 @@ static inline u64 set_pgtable_attr(u64 *page)u64 prot; prot =IOMMU_PAGE_PRESENT |IOMMU_PAGE_RW |IOMMU_PAGE_USER ; - prot |=IOMMU_PAGE_ACCESS |IOMMU_PAGE_DIRTY ; + prot |=IOMMU_PAGE_ACCESS ;return (iommu_virt_to_phys (page) | prot); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 170/634 mtd: powernv: Add check devm_kasprintf() returned value
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit 395999829880a106bb95f0ce34e6e4c2b43c6a5d ]
devm_kasprintf() can return a NULL pointer on failure but this returned value is not checked.
--- drivers/mtd/devices/powernv_flash.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/devices/powernv_flash.c +3 -0
@@ -207,6 +207,9 @@ static int powernv_flash_set_driver_info(struct device *dev,* get them */ mtd->name =devm_kasprintf (dev,GFP_KERNEL ,"%pOFP" , dev->of_node); +if (!mtd->name) +return -ENOMEM ; + mtd->type =MTD_NORFLASH ; mtd->flags =MTD_WRITEABLE ; mtd->size = size;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 171/634 rcu/nocb: Fix RT throttling hrtimer armed from offline CPU
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
[ Upstream commit 9139f93209d1ffd7f489ab19dee01b7c3a1a43d2 ]
After a CPU is marked offline and until it reaches its final trip to idle, rcuo has several opportunities to be woken up, either because a callback has been queued in the meantime or because rcutree_report_cpu_dead() has issued the final deferred NOCB wake up.
If RCU-boosting is enabled, RCU kthreads are set to SCHED_FIFO policy. And if RT-bandwidth is enabled, the related hrtimer might be armed. However this then happens after hrtimers have been migrated at the CPUHP_AP_HRTIMERS_DYING stage, which is broken as reported by the following warning:
Call trace: enqueue_hrtimer+0x7c/0xf8 hrtimer_start_range_ns+0x2b8/0x300 enqueue_task_rt+0x298/0x3f0 enqueue_task+0x94/0x188 ttwu_do_activate+0xb4/0x27c try_to_wake_up+0x2d8/0x79c wake_up_process+0x18/0x28 __wake_nocb_gp+0x80/0x1a0 do_nocb_deferred_wakeup_common+0x3c/0xcc rcu_report_dead+0x68/0x1ac cpuhp_report_idle_dead+0x48/0x9c do_idle+0x288/0x294 cpu_startup_entry+0x34/0x3c secondary_start_kernel+0x138/0x158
Fix this with waking up rcuo using an IPI if necessary. Since the existing API to deal with this situation only handles swait queue, rcuo is only woken up from offline CPUs if it's not already waiting on a grace period. In the worst case some callbacks will just wait for a grace period to complete before being assigned to a subsequent one.
--- kernel/rcu/tree_nocb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/rcu/tree_nocb.h +4 -1
@@ -220,7 +220,10 @@ static bool __wake_nocb_gp(struct rcu_data *rdp_gp,raw_spin_unlock_irqrestore (&rdp_gp->nocb_gp_lock, flags);if (needwake) {trace_rcu_nocb_wake (rcu_state.name, rdp->cpu,TPS ("DoWake" )); -wake_up_process (rdp_gp->nocb_gp_kthread); +if (cpu_is_offline (raw_smp_processor_id ())) +swake_up_one_online (&rdp_gp->nocb_gp_wq); +else +wake_up_process (rdp_gp->nocb_gp_kthread); }return needwake;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 172/634 mtd: rawnand: mtk: Use for_each_child_of_node_scoped()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 8795952679494b111b7b2ba08bb54ac408daca3b ]
Avoids the need for manual cleanup of_node_put() in early exits from the loop.
Stable-dep-of: 2073ae37d550 ("mtd: rawnand: mtk: Fix init error path")
--- drivers/mtd/nand/raw/mtk_nand.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mtd/nand/raw/mtk_nand.c +2 -5
@@ -1432,15 +1432,12 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc,static int mtk_nfc_nand_chips_init (struct device *dev,struct mtk_nfc *nfc) {struct device_node *np = dev->of_node; -struct device_node *nand_np;int ret; -for_each_child_of_node (np, nand_np) { +for_each_child_of_node_scoped (np, nand_np) { ret =mtk_nfc_nand_chip_init (dev, nfc, nand_np); -if (ret) { -of_node_put (nand_np); +if (ret)return ret; - } }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 173/634 mtd: rawnand: mtk: Factorize out the logic cleaning mtk chips
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 81cb3be3261e766a1f8efab9e3154a4f4fd9d03d ]
There are some un-freed resources in one of the error path which would benefit from a helper going through all the registered mtk chips one by one and perform all the necessary cleanup. This is precisely what the remove path does, so let's extract the logic in a helper.
There is no functional change.
Stable-dep-of: 2073ae37d550 ("mtd: rawnand: mtk: Fix init error path")
--- drivers/mtd/nand/raw/mtk_nand.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/mtd/nand/raw/mtk_nand.c +18 -13
@@ -1429,6 +1429,23 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc,return 0 ; } +static void mtk_nfc_nand_chips_cleanup (struct mtk_nfc *nfc) +{ +struct mtk_nfc_nand_chip *mtk_chip; +struct nand_chip *chip; +int ret; + +while (!list_empty (&nfc->chips)) { + mtk_chip =list_first_entry (&nfc->chips, + struct mtk_nfc_nand_chip, node); + chip = &mtk_chip->nand; + ret =mtd_device_unregister (nand_to_mtd (chip)); +WARN_ON (ret); +nand_cleanup (chip); +list_del (&mtk_chip->node); + } +} +static int mtk_nfc_nand_chips_init (struct device *dev,struct mtk_nfc *nfc) {struct device_node *np = dev->of_node;
@@ -1567,20 +1584,8 @@ static int mtk_nfc_probe(struct platform_device *pdev)static void mtk_nfc_remove (struct platform_device *pdev) {struct mtk_nfc *nfc =platform_get_drvdata (pdev); -struct mtk_nfc_nand_chip *mtk_chip; -struct nand_chip *chip; -int ret; - -while (!list_empty (&nfc->chips)) { - mtk_chip =list_first_entry (&nfc->chips, - struct mtk_nfc_nand_chip, node); - chip = &mtk_chip->nand; - ret =mtd_device_unregister (nand_to_mtd (chip)); -WARN_ON (ret); -nand_cleanup (chip); -list_del (&mtk_chip->node); - } +mtk_nfc_nand_chips_cleanup (nfc);mtk_ecc_release (nfc->ecc); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 174/634 mtd: rawnand: mtk: Fix init error path
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 2073ae37d550ea32e8545edaa94ef10b4fef7235 ]
Reviewing a series converting the for_each_chil_of_node() loops into their _scoped variants made me realize there was no cleanup of the already registered NAND devices upon error which may leak memory on systems with more than a chip when this error occurs. We should call the _nand_chips_cleanup() function when this happens.
--- drivers/mtd/nand/raw/mtk_nand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/mtk_nand.c +3 -1
@@ -1453,8 +1453,10 @@ static int mtk_nfc_nand_chips_init(struct device *dev, struct mtk_nfc *nfc)for_each_child_of_node_scoped (np, nand_np) { ret =mtk_nfc_nand_chip_init (dev, nfc, nand_np); -if (ret) +if (ret) { +mtk_nfc_nand_chips_cleanup (nfc);return ret; + } }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 175/634 iommu/arm-smmu-qcom: hide last LPASS SMMU context bank from linux
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Gonzalez <[email protected]>
[ Upstream commit 3a8990b8a778219327c5f8ecf10b5d81377b925a ]
On qcom msm8998, writing to the last context bank of lpass_q6_smmu (base address 0x05100000) produces a system freeze & reboot.
The hardware/hypervisor reports 13 context banks for the LPASS SMMU on msm8998, but only the first 12 are accessible... Override the number of context banks
[ 2.546101] arm-smmu 5100000.iommu: probing hardware configuration... [ 2.552439] arm-smmu 5100000.iommu: SMMUv2 with: [ 2.558945] arm-smmu 5100000.iommu: stage 1 translation [ 2.563627] arm-smmu 5100000.iommu: address translation ops [ 2.568923] arm-smmu 5100000.iommu: non-coherent table walk [ 2.574566] arm-smmu 5100000.iommu: (IDR0.CTTW overridden by FW configuration) [ 2.580220] arm-smmu 5100000.iommu: stream matching with 12 register groups [ 2.587263] arm-smmu 5100000.iommu: 13 context banks (0 stage-2 only) [ 2.614447] arm-smmu 5100000.iommu: Supported page sizes: 0x63315000 [ 2.621358] arm-smmu 5100000.iommu: Stage-1: 36-bit VA -> 36-bit IPA [ 2.627772] arm-smmu 5100000.iommu: preserved 0 boot mappings
Specifically, the crashes occur here:
qsmmu->bypass_cbndx = smmu->num_context_banks - 1; arm_smmu_cb_write(smmu, qsmmu->bypass_cbndx, ARM_SMMU_CB_SCTLR, 0);
and here:
arm_smmu_write_context_bank(smmu, i); arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_FSR, ARM_SMMU_CB_FSR_FAULT);
It is likely that FW reserves the last context bank for its own use, thus a simple work-around is: DON'T USE IT in Linux.
If we decrease the number of context banks, last one will be "hidden".
Stable-dep-of: 19eb465c969f ("iommu/arm-smmu-qcom: apply num_context_bank fixes for SDM630 / SDM660")
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +7 -0
@@ -282,6 +282,13 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)u32 smr;int i; +/* +* MSM8998 LPASS SMMU reports 13 context banks, but accessing +* the last context bank crashes the system. +*/ +if (of_device_is_compatible (smmu->dev->of_node,"qcom,msm8998-smmu-v2" ) && smmu->num_context_banks ==13 ) + smmu->num_context_banks =12 ; +/* * Some platforms support more than the Arm SMMU architected maximum of * 128 stream matching groups. For unknown reasons, the additional
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 176/634 iommu/arm-smmu-qcom: Work around SDM845 Adreno SMMU w/ 16K pages
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 2d42d3ba443706c9164fa0bef4e5fd1c36bc1bd9 ]
SDM845's Adreno SMMU is unique in that it actually advertizes support for 16K (and 32M) pages, which doesn't hold for newer SoCs.
This however, seems either broken in the hardware implementation, the hypervisor middleware that abstracts the SMMU, or there's a bug in the Linux kernel somewhere down the line that nobody managed to track down.
Booting SDM845 with 16K page sizes and drm/msm results in:
*** gpu fault: ttbr0=0000000000000000 iova=000100000000c000 dir=READ type=TRANSLATION source=CP (0,0,0,0)
right after loading the firmware. The GPU then starts spitting out illegal intstruction errors, as it's quite obvious that it got a bogus pointer.
Moreover, it seems like this issue also concerns other implementations of SMMUv2 on Qualcomm SoCs, such as the one on SC7180.
Hide 16K support on such instances to work around this.
Stable-dep-of: 19eb465c969f ("iommu/arm-smmu-qcom: apply num_context_bank fixes for SDM630 / SDM660")
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +9 -0
@@ -345,6 +345,14 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)return 0 ; } +static int qcom_adreno_smmuv2_cfg_probe (struct arm_smmu_device *smmu) +{ +/* Support for 16K pages is advertised on some SoCs, but it doesn't seem to work */ + smmu->features &= ~ARM_SMMU_FEAT_FMT_AARCH64_16K ; + +return 0 ; +} +static void qcom_smmu_write_s2cr (struct arm_smmu_device *smmu,int idx) {struct arm_smmu_s2cr *s2cr = smmu->s2crs + idx;
@@ -443,6 +451,7 @@ static const struct arm_smmu_impl sdm845_smmu_500_impl = {static const struct arm_smmu_impl qcom_adreno_smmu_v2_impl = { .init_context = qcom_adreno_smmu_init_context, + .cfg_probe = qcom_adreno_smmuv2_cfg_probe, .def_domain_type = qcom_smmu_def_domain_type, .alloc_context_bank = qcom_adreno_smmu_alloc_context_bank, .write_sctlr = qcom_adreno_smmu_write_sctlr,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 177/634 iommu/arm-smmu-qcom: apply num_context_bank fixes for SDM630 / SDM660
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 19eb465c969f3d6ed1b98506d3e470e863b41e16 ]
The Qualcomm SDM630 / SDM660 platform requires the same kind of workaround as MSM8998: some IOMMUs have context banks reserved by firmware / TZ, touching those banks resets the board.
Apply the num_context_bank workaround to those two SMMU devices in order to allow them to be used by Linux.
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +13 -1
@@ -286,8 +286,15 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)* MSM8998 LPASS SMMU reports 13 context banks, but accessing * the last context bank crashes the system. */ -if (of_device_is_compatible (smmu->dev->of_node,"qcom,msm8998-smmu-v2" ) && smmu->num_context_banks ==13 ) +if (of_device_is_compatible (smmu->dev->of_node,"qcom,msm8998-smmu-v2" ) && + smmu->num_context_banks ==13 ) { smmu->num_context_banks =12 ; + }else if (of_device_is_compatible (smmu->dev->of_node,"qcom,sdm630-smmu-v2" )) { +if (smmu->num_context_banks ==21 )/* SDM630 / SDM660 A2NOC SMMU */ + smmu->num_context_banks =7 ; +else if (smmu->num_context_banks ==14 )/* SDM630 / SDM660 LPASS SMMU */ + smmu->num_context_banks =13 ; + }/* * Some platforms support more than the Arm SMMU architected maximum of
@@ -350,6 +357,11 @@ static int qcom_adreno_smmuv2_cfg_probe(struct arm_smmu_device *smmu)/* Support for 16K pages is advertised on some SoCs, but it doesn't seem to work */ smmu->features &= ~ARM_SMMU_FEAT_FMT_AARCH64_16K ; +/* TZ protects several last context banks, hide them from Linux */ +if (of_device_is_compatible (smmu->dev->of_node,"qcom,sdm630-smmu-v2" ) && + smmu->num_context_banks ==5 ) + smmu->num_context_banks =2 ; +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 178/634 pmdomain: core: Harden inter-column space in debug summary
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 692c20c4d075bd452acfbbc68200fc226c7c9496 ]
The inter-column space in the debug summary is two spaces. However, in one case, the extra space is handled implicitly in a field width specifier. Make inter-column space explicit to ease future maintenance.
--- drivers/pmdomain/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pmdomain/core.c +1 -1
@@ -3153,7 +3153,7 @@ static int genpd_summary_one(struct seq_file *s,else snprintf (state,sizeof (state),"%s" , status_lookup[genpd->status]); -seq_printf (s,"%-30s %-50s %u" , genpd->name, state, genpd->performance_state); +seq_printf (s,"%-30s %-49s %u" , genpd->name, state, genpd->performance_state);/* * Modifications on the list require holding locks on both
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 179/634 drm/stm: Fix an error handling path in stm_drm_platform_probe()
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 ce7c90bfda2656418c69ba0dd8f8a7536b8928d4 ]
If drm_dev_register() fails, a call to drv_load() must be undone, as already done in the remove function.
--- drivers/gpu/drm/stm/drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +3 -1
@@ -203,12 +203,14 @@ static int stm_drm_platform_probe(struct platform_device *pdev) ret =drm_dev_register (ddev,0 );if (ret) - goto err_put; + goto err_unload;drm_fbdev_dma_setup (ddev,16 );return 0 ; +err_unload: +drv_unload (ddev); err_put:drm_dev_put (ddev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 180/634 drm/stm: ltdc: check memory returned by devm_kzalloc()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit fd39730c58890cd7f0a594231e19bb357f28877c ]
devm_kzalloc() can fail and return NULL pointer. Check its return status. Identified with Coccinelle (kmerr.cocci script).
--- drivers/gpu/drm/stm/ltdc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/stm/ltdc.c +2 -0
@@ -1580,6 +1580,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev,ARRAY_SIZE (ltdc_drm_fmt_ycbcr_sp) + ARRAY_SIZE(ltdc_drm_fmt_ycbcr_fp)) * sizeof(*formats), GFP_KERNEL); +if (!formats) +return NULL ;for (i =0 ; i < ldev->caps.pix_fmt_nb; i++) { drm_fmt = ldev->caps.pix_fmt_drm[i];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/634 drm/amd/display: Add null check for set_output_gamma in dcn30_set_output_transfer_func
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 08ae395ea22fb3d9b318c8bde28c0dfd2f5fa4d2 ]
This commit adds a null check for the set_output_gamma function pointer in the dcn30_set_output_transfer_func function. Previously, set_output_gamma was being checked for nullity at line 386, but then it was being dereferenced without any nullity check at line 401. This could potentially lead to a null pointer dereference error if set_output_gamma is indeed null.
To fix this, we now ensure that set_output_gamma is not null before dereferencing it. We do this by adding a nullity check for set_output_gamma before the call to set_output_gamma at line 401. If set_output_gamma is null, we log an error message and do not call the function.
This fix prevents a potential null pointer dereference error.
drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:401 dcn30_set_output_transfer_func()
error: we previously assumed 'mpc->funcs->set_output_gamma' could be null (see line 386)
drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c
373 bool dcn30_set_output_transfer_func(struct dc *dc,
374 struct pipe_ctx *pipe_ctx,
375 const struct dc_stream_state *stream)
376 {
377 int mpcc_id = pipe_ctx->plane_res.hubp->inst;
378 struct mpc *mpc = pipe_ctx->stream_res.opp->ctx->dc->res_pool->mpc;
379 const struct pwl_params *params = NULL;
380 bool ret = false;
381
382 /* program OGAM or 3DLUT only for the top pipe*/
383 if (pipe_ctx->top_pipe == NULL) {
384 /*program rmu shaper and 3dlut in MPC*/
385 ret = dcn30_set_mpc_shaper_3dlut(pipe_ctx, stream);
386 if (ret == false && mpc->funcs->set_output_gamma) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If this is NULL
387 if (stream->out_transfer_func.type == TF_TYPE_HWPWL)
388 params = &stream->out_transfer_func.pwl;
389 else if (pipe_ctx->stream->out_transfer_func.type ==
390 TF_TYPE_DISTRIBUTED_POINTS &&
391 cm3_helper_translate_curve_to_hw_format(
392 &stream->out_transfer_func,
393 &mpc->blender_params, false))
394 params = &mpc->blender_params;
395 /* there are no ROM LUTs in OUTGAM */
396 if (stream->out_transfer_func.type == TF_TYPE_PREDEFINED)
397 BREAK_TO_DEBUGGER();
398 }
399 }
400
--> 401 mpc->funcs->set_output_gamma(mpc, mpcc_id, params);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Then it will crash
402 return ret;
403 }--- drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c +5 -1
@@ -395,7 +395,11 @@ bool dcn30_set_output_transfer_func(struct dc *dc, } } - mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +if (mpc->funcs->set_output_gamma) + mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +else +DC_LOG_ERROR ("%s: set_output_gamma function pointer is NULL.\n" , __func__); +return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 182/634 drm/amdgpu: properly handle vbios fake edid sizing
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit 8155566a26b8d6c1dd914f06a0c652e4e2f2adf1 ]
The comment in the vbios structure says:
// = 128 means EDID length is 128 bytes, otherwise the EDID length = ucFakeEDIDLength*128
This fake edid struct has not been used in a long time, so I'm not sure if there were actually any boards out there with a non-128 byte EDID, but align the code with the comment.
--- .../gpu/drm/amd/amdgpu/atombios_encoders.c | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/atombios_encoders.c +16 -13
@@ -2065,26 +2065,29 @@ amdgpu_atombios_encoder_get_lcd_info(struct amdgpu_encoder *encoder) fake_edid_record = (ATOM_FAKE_EDID_PATCH_RECORD *)record;if (fake_edid_record->ucFakeEDIDLength) {struct edid *edid; -int edid_size = -max ((int )EDID_LENGTH , (int )fake_edid_record->ucFakeEDIDLength); - edid =kmalloc (edid_size,GFP_KERNEL ); +int edid_size; + +if (fake_edid_record->ucFakeEDIDLength ==128 ) + edid_size = fake_edid_record->ucFakeEDIDLength; +else + edid_size = fake_edid_record->ucFakeEDIDLength *128 ; + edid =kmemdup (&fake_edid_record->ucFakeEDIDString[0 ], + edid_size,GFP_KERNEL );if (edid) { -memcpy ((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0 ], - fake_edid_record->ucFakeEDIDLength); -if (drm_edid_is_valid (edid)) { adev->mode_info.bios_hardcoded_edid = edid; adev->mode_info.bios_hardcoded_edid_size = edid_size; - }else + }else {kfree (edid); + } } + record +=struct_size (fake_edid_record, + ucFakeEDIDString, + edid_size); + }else { +/* empty fake edid record must be 3 bytes long */ + record +=sizeof (ATOM_FAKE_EDID_PATCH_RECORD ) +1 ; } - record += fake_edid_record->ucFakeEDIDLength ? -struct_size (fake_edid_record, - ucFakeEDIDString, - fake_edid_record->ucFakeEDIDLength) : -/* empty fake edid record must be 3 bytes long */ -sizeof (ATOM_FAKE_EDID_PATCH_RECORD ) +1 ;break ;case LCD_PANEL_RESOLUTION_RECORD_TYPE : panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 183/634 drm/radeon: properly handle vbios fake edid sizing
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit 17c6baff3d5f65c8da164137a58742541a060b2f ]
The comment in the vbios structure says:
// = 128 means EDID length is 128 bytes, otherwise the EDID length = ucFakeEDIDLength*128
This fake edid struct has not been used in a long time, so I'm not sure if there were actually any boards out there with a non-128 byte EDID, but align the code with the comment.
--- drivers/gpu/drm/radeon/radeon_atombios.c | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/gpu/drm/radeon/radeon_atombios.c +16 -13
@@ -1717,26 +1717,29 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct fake_edid_record = (ATOM_FAKE_EDID_PATCH_RECORD *)record;if (fake_edid_record->ucFakeEDIDLength) {struct edid *edid; -int edid_size = -max ((int )EDID_LENGTH , (int )fake_edid_record->ucFakeEDIDLength); - edid =kmalloc (edid_size,GFP_KERNEL ); +int edid_size; + +if (fake_edid_record->ucFakeEDIDLength ==128 ) + edid_size = fake_edid_record->ucFakeEDIDLength; +else + edid_size = fake_edid_record->ucFakeEDIDLength *128 ; + edid =kmemdup (&fake_edid_record->ucFakeEDIDString[0 ], + edid_size,GFP_KERNEL );if (edid) { -memcpy ((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0 ], - fake_edid_record->ucFakeEDIDLength); -if (drm_edid_is_valid (edid)) { rdev->mode_info.bios_hardcoded_edid = edid; rdev->mode_info.bios_hardcoded_edid_size = edid_size; - }else + }else {kfree (edid); + } } + record +=struct_size (fake_edid_record, + ucFakeEDIDString, + edid_size); + }else { +/* empty fake edid record must be 3 bytes long */ + record +=sizeof (ATOM_FAKE_EDID_PATCH_RECORD ) +1 ; } - record += fake_edid_record->ucFakeEDIDLength ? -struct_size (fake_edid_record, - ucFakeEDIDString, - fake_edid_record->ucFakeEDIDLength) : -/* empty fake edid record must be 3 bytes long */ -sizeof (ATOM_FAKE_EDID_PATCH_RECORD ) +1 ;break ;case LCD_PANEL_RESOLUTION_RECORD_TYPE : panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 184/634 scsi: smartpqi: revert propagate-the-multipath-failure-to-SML-quickly
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gilbert Wu <[email protected]>
[ Upstream commit f1393d52e6cda9c20f12643cbecf1e1dc357e0e2 ]
Correct a rare multipath failure issue by reverting commit 94a68c814328 ("scsi: smartpqi: Quickly propagate path failures to SCSI midlayer") [1].
Reason for revert: The patch propagated the path failure to SML quickly when one of the path fails during IO and AIO path gets disabled for a multipath device.
But it created a new issue: when creating a volume on an encryption-enabled controller, the firmware reports the AIO path is disabled, which cause the driver to report a path failure to SML for a multipath device.
There will be a new fix to handle "Illegal request" and "Invalid field in parameter list" on RAID path when the AIO path is disabled on a multipath device.
[1] https://lore.kernel.org/all/[email protected]/
--- drivers/scsi/smartpqi/smartpqi_init.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -18
@@ -2354,14 +2354,6 @@ static inline void pqi_mask_device(u8 *scsi3addr) scsi3addr[3 ] |=0xc0 ; } -static inline bool pqi_is_multipath_device (struct pqi_scsi_dev *device) -{ -if (pqi_is_logical_device (device)) -return false; - -return (device->path_map & (device->path_map -1 )) !=0 ; -} -static inline bool pqi_expose_device (struct pqi_scsi_dev *device) {return !device->is_physical_device || !pqi_skip_device (device->scsi3addr);
@@ -3258,14 +3250,12 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request)int residual_count;int xfer_count;bool device_offline; -struct pqi_scsi_dev *device; scmd = io_request->scmd; error_info = io_request->error_info; host_byte =DID_OK ; sense_data_length =0 ; device_offline = false; - device = scmd->device->hostdata;switch (error_info->service_response) {case PQI_AIO_SERV_RESPONSE_COMPLETE :
@@ -3290,14 +3280,8 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request)break ;case PQI_AIO_STATUS_AIO_PATH_DISABLED :pqi_aio_path_disabled (io_request); -if (pqi_is_multipath_device (device)) { -pqi_device_remove_start (device); - host_byte =DID_NO_CONNECT ; - scsi_status =SAM_STAT_CHECK_CONDITION ; - }else { - scsi_status =SAM_STAT_GOOD ; - io_request->status = -EAGAIN ; - } + scsi_status =SAM_STAT_GOOD ; + io_request->status = -EAGAIN ;break ;case PQI_AIO_STATUS_NO_PATH_TO_DEVICE :case PQI_AIO_STATUS_INVALID_DEVICE :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 185/634 scsi: NCR5380: Check for phase match during PDMA fixup
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
[ Upstream commit 5768718da9417331803fc4bc090544c2a93b88dc ]
It's not an error for a target to change the bus phase during a transfer. Unfortunately, the FLAG_DMA_FIXUP workaround does not allow for that -- a phase change produces a DRQ timeout error and the device borken flag will be set.
Check the phase match bit during FLAG_DMA_FIXUP processing. Don't forget to decrement the command residual. While we are here, change shost_printk() into scmd_printk() for better consistency with other DMA error messages.
--- drivers/scsi/NCR5380.c | 78 +++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-)
drivers/scsi/NCR5380.c +39 -39
@@ -1485,6 +1485,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char **data) {struct NCR5380_hostdata *hostdata =shost_priv (instance); +struct NCR5380_cmd *ncmd =NCR5380_to_ncmd (hostdata->connected);int c = *count;unsigned char p = *phase;unsigned char *d = *data;
@@ -1496,7 +1497,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance,return -1 ; } -NCR5380_to_ncmd (hostdata->connected)->phase = p; + ncmd->phase = p;if (p &SR_IO ) {if (hostdata->read_overruns)
@@ -1608,45 +1609,44 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance,* request. */ -if (hostdata->flags &FLAG_DMA_FIXUP ) { -if (p &SR_IO ) { -/* -* The workaround was to transfer fewer bytes than we -* intended to with the pseudo-DMA read function, wait for -* the chip to latch the last byte, read it, and then disable -* pseudo-DMA mode. -* -* After REQ is asserted, the NCR5380 asserts DRQ and ACK. -* REQ is deasserted when ACK is asserted, and not reasserted -* until ACK goes false. Since the NCR5380 won't lower ACK -* until DACK is asserted, which won't happen unless we twiddle -* the DMA port or we take the NCR5380 out of DMA mode, we -* can guarantee that we won't handshake another extra -* byte. -*/ - -if (NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG , -BASR_DRQ ,BASR_DRQ ,0 ) <0 ) { - result =-1 ; -shost_printk (KERN_ERR , instance,"PDMA read: DRQ timeout\n" ); - } -if (NCR5380_poll_politely (hostdata,STATUS_REG , -SR_REQ ,0 ,0 ) <0 ) { - result =-1 ; -shost_printk (KERN_ERR , instance,"PDMA read: !REQ timeout\n" ); - } - d[*count -1 ] =NCR5380_read (INPUT_DATA_REG ); - }else { -/* -* Wait for the last byte to be sent. If REQ is being asserted for -* the byte we're interested, we'll ACK it and it will go false. -*/ -if (NCR5380_poll_politely2 (hostdata, -BUS_AND_STATUS_REG ,BASR_DRQ ,BASR_DRQ , -BUS_AND_STATUS_REG ,BASR_PHASE_MATCH ,0 ,0 ) <0 ) { - result =-1 ; -shost_printk (KERN_ERR , instance,"PDMA write: DRQ and phase timeout\n" ); +if ((hostdata->flags &FLAG_DMA_FIXUP ) && + (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) { +/* +* The workaround was to transfer fewer bytes than we +* intended to with the pseudo-DMA receive function, wait for +* the chip to latch the last byte, read it, and then disable +* DMA mode. +* +* After REQ is asserted, the NCR5380 asserts DRQ and ACK. +* REQ is deasserted when ACK is asserted, and not reasserted +* until ACK goes false. Since the NCR5380 won't lower ACK +* until DACK is asserted, which won't happen unless we twiddle +* the DMA port or we take the NCR5380 out of DMA mode, we +* can guarantee that we won't handshake another extra +* byte. +* +* If sending, wait for the last byte to be sent. If REQ is +* being asserted for the byte we're interested, we'll ACK it +* and it will go false. +*/ +if (!NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG , +BASR_DRQ ,BASR_DRQ ,0 )) { +if ((p &SR_IO ) && + (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) { +if (!NCR5380_poll_politely (hostdata,STATUS_REG , +SR_REQ ,0 ,0 )) { + d[c] =NCR5380_read (INPUT_DATA_REG ); + --ncmd->this_residual; + }else { + result =-1 ; +scmd_printk (KERN_ERR , hostdata->connected, +"PDMA fixup: !REQ timeout\n" ); + } } + }else if (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH ) { + result =-1 ; +scmd_printk (KERN_ERR , hostdata->connected, +"PDMA fixup: DRQ timeout\n" ); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 186/634 drm/amd/amdgpu: Properly tune the size of struct
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
[ Upstream commit 0cee47cde41e22712c034ae961076067d4ac13a0 ]
The struct assertion is failed because sparse cannot parse #pragma pack(push, 1) and #pragma pack(pop) correctly. GCC's output is still 1-byte-aligned. No harm to memory layout.
The error can be filtered out by sparse-diff, but sometimes multiple lines queezed into one, making the sparse-diff thinks its a new error. I'm trying to aviod this by fixing errors.
--- drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +2 -2
@@ -213,7 +213,7 @@ struct amd_sriov_msg_pf2vf_info {uint32_t gpu_capacity;/* reserved */ uint32_t reserved[256 -AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE ]; -}; +} __packed;struct amd_sriov_msg_vf2pf_info_header {/* the total structure size in byte */
@@ -273,7 +273,7 @@ struct amd_sriov_msg_vf2pf_info {uint32_t mes_info_size;/* reserved */ uint32_t reserved[256 -AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE ]; -}; +} __packed;/* mailbox message send from guest to host */ enum amd_sriov_mailbox_request_message {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 187/634 drm/rockchip: vop: Allow 4096px width scaling
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Bee <[email protected]>
[ Upstream commit 0ef968d91a20b5da581839f093f98f7a03a804f7 ]
There is no reason to limit VOP scaling to 3840px width, the limit of RK3288, when there are newer VOP versions that support 4096px width.
Change to enforce a maximum of 4096px width plane scaling, the maximum supported output width of the VOP versions supported by this driver.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2 -2
@@ -396,8 +396,8 @@ static void scl_vop_cal_scl_fac(struct vop *vop, const struct vop_win_data *win,if (info->is_yuv) is_yuv = true; -if (dst_w >3840 ) { -DRM_DEV_ERROR (vop->dev,"Maximum dst width (3840) exceeded\n" ); +if (dst_w >4096 ) { +DRM_DEV_ERROR (vop->dev,"Maximum dst width (4096) exceeded\n" );return ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 188/634 drm/rockchip: dw_hdmi: Fix reading EDID when using a forced mode
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Karlman <[email protected]>
[ Upstream commit a5d024541ec466f428e6c514577d511a40779c7b ]
EDID cannot be read on RK3328 until after read_hpd has been called and correct io voltage has been configured based on connection status.
When a forced mode is used, e.g. video=1920x1080@60e, the connector detect ops, that in turn normally calls the read_hpd, never gets called.
This result in reading EDID to fail in connector get_modes ops.
Call dw_hdmi_rk3328_read_hpd at end of dw_hdmi_rk3328_setup_hpd to correct io voltage and allow reading EDID after setup_hpd.
--- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +2 -0
@@ -434,6 +434,8 @@ static void dw_hdmi_rk3328_setup_hpd(struct dw_hdmi *dw_hdmi, void *data)HIWORD_UPDATE (RK3328_HDMI_SDAIN_MSK |RK3328_HDMI_SCLIN_MSK ,RK3328_HDMI_SDAIN_MSK |RK3328_HDMI_SCLIN_MSK | RK3328_HDMI_HPD_IOE)); + +dw_hdmi_rk3328_read_hpd (dw_hdmi, data); }static const struct dw_hdmi_phy_ops rk3228_hdmi_phy_ops = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 189/634 drm/radeon/evergreen_cs: fix int overflow errors in cs track offsets
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
[ Upstream commit 3fbaf475a5b8361ebee7da18964db809e37518b7 ]
Several cs track offsets (such as 'track->db_s_read_offset') either are initialized with or plainly take big enough values that, once shifted 8 bits left, may be hit with integer overflow if the resulting values end up going over u32 limit.
Same goes for a few instances of 'surf.layer_size * mslice' multiplications that are added to 'offset' variable - they may potentially overflow as well and need to be validated properly.
While some debug prints in this code section take possible overflow issues into account, simply casting to (unsigned long) may be erroneous in its own way, as depending on CPU architecture one is liable to get different results.
Fix said problems by:
- casting 'offset' to fixed u64 data type instead of ambiguous unsigned long.
- casting one of the operands in vulnerable to integer overflow cases to u64.
- adjust format specifiers in debug prints to properly represent 'offset' values.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/gpu/drm/radeon/evergreen_cs.c | 62 +++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-)
drivers/gpu/drm/radeon/evergreen_cs.c +31 -31
@@ -395,7 +395,7 @@ static int evergreen_cs_track_validate_cb(struct radeon_cs_parser *p, unsigned istruct evergreen_cs_track *track = p->track;struct eg_surface surf;unsigned pitch, slice, mslice; -unsigned long offset; +u64 offset;int r; mslice =G_028C6C_SLICE_MAX (track->cb_color_view[id]) +1 ;
@@ -433,14 +433,14 @@ static int evergreen_cs_track_validate_cb(struct radeon_cs_parser *p, unsigned ireturn r; } - offset = track->cb_color_bo_offset[id] <<8 ; + offset = (u64 )track->cb_color_bo_offset[id] <<8 ;if (offset & (surf.base_align -1 )) { -dev_warn (p->dev,"%s:%d cb[%d] bo base %ld not aligned with %ld\n" , +dev_warn (p->dev,"%s:%d cb[%d] bo base %llu not aligned with %ld\n" , __func__, __LINE__, id, offset, surf.base_align);return -EINVAL ; } - offset += surf.layer_size * mslice; + offset += (u64 )surf.layer_size * mslice;if (offset >radeon_bo_size (track->cb_color_bo[id])) {/* old ddx are broken they allocate bo with w*h*bpp but * program slice with ALIGN(h, 8), catch this and patch
@@ -448,14 +448,14 @@ static int evergreen_cs_track_validate_cb(struct radeon_cs_parser *p, unsigned i*/ if (!surf.mode) {uint32_t *ib = p->ib.ptr; -unsigned long tmp, nby, bsize, size, min =0 ; +u64 tmp, nby, bsize, size, min =0 ;/* find the height the ddx wants */ if (surf.nby >8 ) { min = surf.nby -8 ; } bsize =radeon_bo_size (track->cb_color_bo[id]); - tmp = track->cb_color_bo_offset[id] <<8 ; + tmp = (u64 )track->cb_color_bo_offset[id] <<8 ;for (nby = surf.nby; nby > min; nby--) { size = nby * surf.nbx * surf.bpe * surf.nsamples;if ((tmp + size * mslice) <= bsize) {
@@ -467,7 +467,7 @@ static int evergreen_cs_track_validate_cb(struct radeon_cs_parser *p, unsigned i slice = ((nby * surf.nbx) /64 ) -1 ;if (!evergreen_surface_check (p, &surf,"cb" )) {/* check if this one works */ - tmp += surf.layer_size * mslice; + tmp += (u64 )surf.layer_size * mslice;if (tmp <= bsize) { ib[track->cb_color_slice_idx[id]] = slice; goto old_ddx_ok;
@@ -476,9 +476,9 @@ static int evergreen_cs_track_validate_cb(struct radeon_cs_parser *p, unsigned i } }dev_warn (p->dev,"%s:%d cb[%d] bo too small (layer size %d, " -"offset %d, max layer %d, bo size %ld, slice %d)\n" , +"offset %llu, max layer %d, bo size %ld, slice %d)\n" , __func__, __LINE__, id, surf.layer_size, - track->cb_color_bo_offset[id] <<8 , mslice, + (u64 )track->cb_color_bo_offset[id] <<8 , mslice,radeon_bo_size (track->cb_color_bo[id]), slice); dev_warn(p->dev, "%s:%d problematic surf: (%d %d) (%d %d %d %d %d %d %d)\n", __func__, __LINE__, surf.nbx, surf.nby,
@@ -562,7 +562,7 @@ static int evergreen_cs_track_validate_stencil(struct radeon_cs_parser *p)struct evergreen_cs_track *track = p->track;struct eg_surface surf;unsigned pitch, slice, mslice; -unsigned long offset; +u64 offset;int r; mslice =G_028008_SLICE_MAX (track->db_depth_view) +1 ;
@@ -608,18 +608,18 @@ static int evergreen_cs_track_validate_stencil(struct radeon_cs_parser *p)return r; } - offset = track->db_s_read_offset <<8 ; + offset = (u64 )track->db_s_read_offset <<8 ;if (offset & (surf.base_align -1 )) { -dev_warn (p->dev,"%s:%d stencil read bo base %ld not aligned with %ld\n" , +dev_warn (p->dev,"%s:%d stencil read bo base %llu not aligned with %ld\n" , __func__, __LINE__, offset, surf.base_align);return -EINVAL ; } - offset += surf.layer_size * mslice; + offset += (u64 )surf.layer_size * mslice;if (offset >radeon_bo_size (track->db_s_read_bo)) {dev_warn (p->dev,"%s:%d stencil read bo too small (layer size %d, " -"offset %ld, max layer %d, bo size %ld)\n" , +"offset %llu, max layer %d, bo size %ld)\n" , __func__, __LINE__, surf.layer_size, - (unsigned long )track->db_s_read_offset <<8 , mslice, + (u64 )track->db_s_read_offset <<8 , mslice,radeon_bo_size (track->db_s_read_bo)); dev_warn(p->dev, "%s:%d stencil invalid (0x%08x 0x%08x 0x%08x 0x%08x)\n", __func__, __LINE__, track->db_depth_size,
@@ -627,18 +627,18 @@ static int evergreen_cs_track_validate_stencil(struct radeon_cs_parser *p)return -EINVAL ; } - offset = track->db_s_write_offset <<8 ; + offset = (u64 )track->db_s_write_offset <<8 ;if (offset & (surf.base_align -1 )) { -dev_warn (p->dev,"%s:%d stencil write bo base %ld not aligned with %ld\n" , +dev_warn (p->dev,"%s:%d stencil write bo base %llu not aligned with %ld\n" , __func__, __LINE__, offset, surf.base_align);return -EINVAL ; } - offset += surf.layer_size * mslice; + offset += (u64 )surf.layer_size * mslice;if (offset >radeon_bo_size (track->db_s_write_bo)) {dev_warn (p->dev,"%s:%d stencil write bo too small (layer size %d, " -"offset %ld, max layer %d, bo size %ld)\n" , +"offset %llu, max layer %d, bo size %ld)\n" , __func__, __LINE__, surf.layer_size, - (unsigned long )track->db_s_write_offset <<8 , mslice, + (u64 )track->db_s_write_offset <<8 , mslice,radeon_bo_size (track->db_s_write_bo));return -EINVAL ; }
@@ -659,7 +659,7 @@ static int evergreen_cs_track_validate_depth(struct radeon_cs_parser *p)struct evergreen_cs_track *track = p->track;struct eg_surface surf;unsigned pitch, slice, mslice; -unsigned long offset; +u64 offset;int r; mslice =G_028008_SLICE_MAX (track->db_depth_view) +1 ;
@@ -706,34 +706,34 @@ static int evergreen_cs_track_validate_depth(struct radeon_cs_parser *p)return r; } - offset = track->db_z_read_offset <<8 ; + offset = (u64 )track->db_z_read_offset <<8 ;if (offset & (surf.base_align -1 )) { -dev_warn (p->dev,"%s:%d stencil read bo base %ld not aligned with %ld\n" , +dev_warn (p->dev,"%s:%d stencil read bo base %llu not aligned with %ld\n" , __func__, __LINE__, offset, surf.base_align);return -EINVAL ; } - offset += surf.layer_size * mslice; + offset += (u64 )surf.layer_size * mslice;if (offset >radeon_bo_size (track->db_z_read_bo)) {dev_warn (p->dev,"%s:%d depth read bo too small (layer size %d, " -"offset %ld, max layer %d, bo size %ld)\n" , +"offset %llu, max layer %d, bo size %ld)\n" , __func__, __LINE__, surf.layer_size, - (unsigned long )track->db_z_read_offset <<8 , mslice, + (u64 )track->db_z_read_offset <<8 , mslice,radeon_bo_size (track->db_z_read_bo));return -EINVAL ; } - offset = track->db_z_write_offset <<8 ; + offset = (u64 )track->db_z_write_offset <<8 ;if (offset & (surf.base_align -1 )) { -dev_warn (p->dev,"%s:%d stencil write bo base %ld not aligned with %ld\n" , +dev_warn (p->dev,"%s:%d stencil write bo base %llu not aligned with %ld\n" , __func__, __LINE__, offset, surf.base_align);return -EINVAL ; } - offset += surf.layer_size * mslice; + offset += (u64 )surf.layer_size * mslice;if (offset >radeon_bo_size (track->db_z_write_bo)) {dev_warn (p->dev,"%s:%d depth write bo too small (layer size %d, " -"offset %ld, max layer %d, bo size %ld)\n" , +"offset %llu, max layer %d, bo size %ld)\n" , __func__, __LINE__, surf.layer_size, - (unsigned long )track->db_z_write_offset <<8 , mslice, + (u64 )track->db_z_write_offset <<8 , mslice,radeon_bo_size (track->db_z_write_bo));return -EINVAL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 190/634 drm/bridge: lontium-lt8912b: Validate mode in drm_bridge_funcs::mode_valid()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Ying <[email protected]>
[ Upstream commit fe828fbd87786238b30f44cafd698d975d956c97 ]
If the bridge is attached with the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag set, this driver won't initialize a connector and hence display mode won't be validated in drm_connector_helper_funcs::mode_valid(). So, move the mode validation from drm_connector_helper_funcs::mode_valid() to drm_bridge_funcs::mode_valid(), because the mode validation is always done for the bridge.
--- drivers/gpu/drm/bridge/lontium-lt8912b.c | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/gpu/drm/bridge/lontium-lt8912b.c +18 -17
@@ -422,22 +422,6 @@ static const struct drm_connector_funcs lt8912_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static enum drm_mode_status -lt8912_connector_mode_valid (struct drm_connector *connector, -struct drm_display_mode *mode) -{ -if (mode->clock >150000 ) -return MODE_CLOCK_HIGH ; - -if (mode->hdisplay >1920 ) -return MODE_BAD_HVALUE ; - -if (mode->vdisplay >1080 ) -return MODE_BAD_VVALUE ; - -return MODE_OK ; -} -static int lt8912_connector_get_modes (struct drm_connector *connector) {const struct drm_edid *drm_edid;
@@ -463,7 +447,6 @@ static int lt8912_connector_get_modes(struct drm_connector *connector)static const struct drm_connector_helper_funcs lt8912_connector_helper_funcs = { .get_modes = lt8912_connector_get_modes, - .mode_valid = lt8912_connector_mode_valid, }; static void lt8912_bridge_mode_set(struct drm_bridge *bridge,
@@ -605,6 +588,23 @@ static void lt8912_bridge_detach(struct drm_bridge *bridge)drm_bridge_hpd_disable (lt->hdmi_port); } +static enum drm_mode_status +lt8912_bridge_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) +{ +if (mode->clock >150000 ) +return MODE_CLOCK_HIGH ; + +if (mode->hdisplay >1920 ) +return MODE_BAD_HVALUE ; + +if (mode->vdisplay >1080 ) +return MODE_BAD_VVALUE ; + +return MODE_OK ; +} +static enum drm_connector_status lt8912_bridge_detect (struct drm_bridge *bridge) {
@@ -635,6 +635,7 @@ static const struct drm_edid *lt8912_bridge_edid_read(struct drm_bridge *bridge,static const struct drm_bridge_funcs lt8912_bridge_funcs = { .attach = lt8912_bridge_attach, .detach = lt8912_bridge_detach, + .mode_valid = lt8912_bridge_mode_valid, .mode_set = lt8912_bridge_mode_set, .enable = lt8912_bridge_enable, .detect = lt8912_bridge_detect,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 191/634 drm/vc4: hdmi: Handle error case of pm_runtime_resume_and_get
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit f1a54e860b1bc8d824925b5a77f510913880e8d6 ]
The commit 0f5251339eda ("drm/vc4: hdmi: Make sure the controller is powered in detect") introduced the necessary power management handling to avoid register access while controller is powered down. Unfortunately it just print a warning if pm_runtime_resume_and_get() fails and proceed anyway.
This could happen during suspend to idle. So we must assume it is unsafe to access the HDMI register. So bail out properly.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +7 -1
@@ -462,6 +462,7 @@ static int vc4_hdmi_connector_detect_ctx(struct drm_connector *connector, {struct vc4_hdmi *vc4_hdmi =connector_to_vc4_hdmi (connector);enum drm_connector_status status = connector_status_disconnected; +int ret;/* * NOTE: This function should really take vc4_hdmi->mutex, but
@@ -474,7 +475,12 @@ static int vc4_hdmi_connector_detect_ctx(struct drm_connector *connector,* the lock for now. */ -WARN_ON (pm_runtime_resume_and_get (&vc4_hdmi->pdev->dev)); + ret =pm_runtime_resume_and_get (&vc4_hdmi->pdev->dev); +if (ret) { +drm_err_once (connector->dev,"Failed to retain HDMI power domain: %d\n" , + ret); +return connector_status_unknown; + }if (vc4_hdmi->hpd_gpio) {if (gpiod_get_value_cansleep (vc4_hdmi->hpd_gpio))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 192/634 scsi: elx: libefc: Fix potential use after free in efc_nport_vport_del()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 2e4b02fad094976763af08fec2c620f4f8edd9ae ]
The kref_put() function will call nport->release if the refcount drops to zero. The nport->release release function is _efc_nport_free() which frees "nport". But then we dereference "nport" on the next line which is a use after free. Re-order these lines to avoid the use after free.
--- drivers/scsi/elx/libefc/efc_nport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/elx/libefc/efc_nport.c +1 -1
@@ -705,9 +705,9 @@ efc_nport_vport_del(struct efc *efc, struct efc_domain *domain,spin_lock_irqsave (&efc->lock, flags);list_for_each_entry (nport, &domain->nport_list, list_entry) {if (nport->wwpn == wwpn && nport->wwnn == wwnn) { -kref_put (&nport->ref, nport->release);/* Shutdown this NPORT */ efc_sm_post_event (&nport->sm,EFC_EVT_SHUTDOWN ,NULL ); +kref_put (&nport->ref, nport->release);break ; } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 193/634 jfs: fix out-of-bounds in dbNextAG() and diAlloc()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
[ Upstream commit e63866a475562810500ea7f784099bfe341e761a ]
In dbNextAG() , there is no check for the case where bmp->db_numag is greater or same than MAXAG due to a polluted image, which causes an out-of-bounds. Therefore, a bounds check should be added in dbMount().
And in dbNextAG(), a check for the case where agpref is greater than bmp->db_numag should be added, so an out-of-bounds exception should be prevented.
Additionally, a check for the case where agno is greater or same than MAXAG should be added in diAlloc() to prevent out-of-bounds.
--- fs/jfs/jfs_dmap.c | 4 ++-- fs/jfs/jfs_imap.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/jfs/jfs_dmap.c +2 -2
@@ -187,7 +187,7 @@ int dbMount(struct inode *ipbmap) } bmp->db_numag =le32_to_cpu (dbmp_le->dn_numag); -if (!bmp->db_numag) { +if (!bmp->db_numag || bmp->db_numag >=MAXAG ) { err = -EINVAL ; goto err_release_metapage; }
@@ -652,7 +652,7 @@ int dbNextAG(struct inode *ipbmap)* average free space. */ for (i =0 ; i < bmp->db_numag; i++, agpref++) { -if (agpref == bmp->db_numag) +if (agpref >= bmp->db_numag) agpref =0 ;if (atomic_read (&bmp->db_active[agpref]))
fs/jfs/jfs_imap.c +1 -1
@@ -1360,7 +1360,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)/* get the ag number of this iag */ agno =BLKTOAG (JFS_IP (pip)->agstart,JFS_SBI (pip->i_sb)); dn_numag =JFS_SBI (pip->i_sb)->bmap->db_numag; -if (agno <0 || agno > dn_numag) +if (agno <0 || agno > dn_numag || agno >=MAXAG )return -EIO ;if (atomic_read (&JFS_SBI (pip->i_sb)->bmap->db_active[agno])) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 194/634 drm/mediatek: Fix missing configuration flags in mtk_crtc_ddp_config()
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 fe30bae552ce27b9fefe0b12db1544e73d07325f ]
In mtk_crtc_ddp_config(), mtk_crtc will use some configuration flags to generate instructions to cmdq_handle, such as:
state->pending_config
mtk_crtc->pending_planes
plane_state->pending.config
mtk_crtc->pending_async_planes plane_state->pending.async_config
These configuration flags may be set to false when a GCE IRQ comes calling ddp_cmdq_cb(). This may result in missing prepare instructions, especially if mtk_crtc_update_config() with the flase need_vblank (no need to wait for vblank) cases.
Therefore, the mtk_crtc->config_updating flag is set at the beginning of mtk_crtc_update_config() to ensure that these configuration flags won't be changed when the mtk_crtc_ddp_config() is preparing instructions. But somehow the ddp_cmdq_cb() didn't use the mtk_crtc->config_updating flag to prevent those pending config flags from being cleared.
To avoid missing the configuration when generating the config instruction, the config_updating flag should be added into ddp_cmdq_cb() and be protected with spin_lock.
--- drivers/gpu/drm/mediatek/mtk_crtc.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/mediatek/mtk_crtc.c +27 -0
@@ -69,6 +69,8 @@ struct mtk_crtc {/* lock for display hardware access */ struct mutex hw_lock;bool config_updating; +/* lock for config_updating to cmd buffer */ +spinlock_t config_lock; };struct mtk_crtc_state {
@@ -106,11 +108,16 @@ static void mtk_crtc_finish_page_flip(struct mtk_crtc *mtk_crtc)static void mtk_drm_finish_page_flip (struct mtk_crtc *mtk_crtc) { +unsigned long flags; +drm_crtc_handle_vblank (&mtk_crtc->base); + +spin_lock_irqsave (&mtk_crtc->config_lock, flags);if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {mtk_crtc_finish_page_flip (mtk_crtc); mtk_crtc->pending_needs_vblank = false; } +spin_unlock_irqrestore (&mtk_crtc->config_lock, flags); }#if IS_REACHABLE (CONFIG_MTK_CMDQ )
@@ -308,12 +315,19 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) struct mtk_crtc *mtk_crtc = container_of(cmdq_cl, struct mtk_crtc, cmdq_client);struct mtk_crtc_state *state;unsigned int i; +unsigned long flags;if (data->sta <0 )return ; state =to_mtk_crtc_state (mtk_crtc->base.state); +spin_lock_irqsave (&mtk_crtc->config_lock, flags); +if (mtk_crtc->config_updating) { +spin_unlock_irqrestore (&mtk_crtc->config_lock, flags); + goto ddp_cmdq_cb_out; + } + state->pending_config = false;if (mtk_crtc->pending_planes) {
@@ -340,6 +354,10 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) mtk_crtc->pending_async_planes = false; } +spin_unlock_irqrestore (&mtk_crtc->config_lock, flags); + +ddp_cmdq_cb_out: + mtk_crtc->cmdq_vblank_cnt =0 ;wake_up (&mtk_crtc->cb_blocking_queue); }
@@ -569,9 +587,14 @@ static void mtk_crtc_update_config(struct mtk_crtc *mtk_crtc, bool needs_vblank)struct mtk_drm_private *priv = crtc->dev->dev_private;unsigned int pending_planes =0 , pending_async_planes =0 ;int i; +unsigned long flags;mutex_lock (&mtk_crtc->hw_lock); + +spin_lock_irqsave (&mtk_crtc->config_lock, flags); mtk_crtc->config_updating = true; +spin_unlock_irqrestore (&mtk_crtc->config_lock, flags); +if (needs_vblank) mtk_crtc->pending_needs_vblank = true;
@@ -625,7 +648,10 @@ static void mtk_crtc_update_config(struct mtk_crtc *mtk_crtc, bool needs_vblank) mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0); }#endif +spin_lock_irqsave (&mtk_crtc->config_lock, flags); mtk_crtc->config_updating = false; +spin_unlock_irqrestore (&mtk_crtc->config_lock, flags); +mutex_unlock (&mtk_crtc->hw_lock); }
@@ -1068,6 +1094,7 @@ int mtk_crtc_create(struct drm_device *drm_dev, const unsigned int *path,drm_mode_crtc_set_gamma_size (&mtk_crtc->base, gamma_lut_size);drm_crtc_enable_color_mgmt (&mtk_crtc->base,0 , has_ctm, gamma_lut_size);mutex_init (&mtk_crtc->hw_lock); +spin_lock_init (&mtk_crtc->config_lock);#if IS_REACHABLE (CONFIG_MTK_CMDQ ) i = priv->mbox_index++;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 195/634 drm/mediatek: Use spin_lock_irqsave() for CRTC event lock
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fei Shao <[email protected]>
[ Upstream commit be03b30b7aa99aca876fbc7c1c1b73b2d0339321 ]
Use the state-aware spin_lock_irqsave() and spin_unlock_irqrestore() to avoid unconditionally re-enabling the local interrupts.
--- drivers/gpu/drm/mediatek/mtk_crtc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_crtc.c +3 -2
@@ -467,6 +467,7 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_crtc *mtk_crtc) {struct drm_device *drm = mtk_crtc->base.dev;struct drm_crtc *crtc = &mtk_crtc->base; +unsigned long flags;int i;for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) {
@@ -498,10 +499,10 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_crtc *mtk_crtc)pm_runtime_put (drm->dev);if (crtc->state->event && !crtc->state->active) { -spin_lock_irq (&crtc->dev->event_lock); +spin_lock_irqsave (&crtc->dev->event_lock, flags);drm_crtc_send_vblank_event (crtc, crtc->state->event); crtc->state->event =NULL ; -spin_unlock_irq (&crtc->dev->event_lock); +spin_unlock_irqrestore (&crtc->dev->event_lock, flags); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 196/634 powerpc/8xx: Fix initial memory mapping
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 f9f2bff64c2f0dbee57be3d8c2741357ad3d05e6 ]
Commit cf209951fa7f ("powerpc/8xx: Map linear memory with huge pages") introduced an initial mapping of kernel TEXT using PAGE_KERNEL_TEXT, but the pages that contain kernel TEXT may also contain kernel RODATA, and depending on selected debug options PAGE_KERNEL_TEXT may be either RWX or ROX. RODATA must be writable during init because it also contains ro_after_init data.
So use PAGE_KERNEL_X instead to be sure it is RWX.
--- arch/powerpc/mm/nohash/8xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/nohash/8xx.c +2 -2
@@ -154,11 +154,11 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)mmu_mapin_immr (); -mmu_mapin_ram_chunk (0 , boundary,PAGE_KERNEL_TEXT , true); +mmu_mapin_ram_chunk (0 , boundary,PAGE_KERNEL_X , true);if (debug_pagealloc_enabled_or_kfence ()) { top = boundary; }else { -mmu_mapin_ram_chunk (boundary, einittext8,PAGE_KERNEL_TEXT , true); +mmu_mapin_ram_chunk (boundary, einittext8,PAGE_KERNEL_X , true);mmu_mapin_ram_chunk (einittext8, top,PAGE_KERNEL , true); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 197/634 powerpc/8xx: Fix kernel vs user address comparison
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 65a82e117ffeeab0baf6f871a1cab11a28ace183 ]
Since commit 9132a2e82adc ("powerpc/8xx: Define a MODULE area below kernel text"), module exec space is below PAGE_OFFSET so not only space above PAGE_OFFSET, but space above TASK_SIZE need to be seen as kernel space.
Until now the problem went undetected because by default TASK_SIZE is 0x8000000 which means address space is determined by just checking upper address bit. But when TASK_SIZE is over 0x80000000, PAGE_OFFSET is used for comparison, leading to thinking module addresses are part of user space.
Fix it by using TASK_SIZE instead of PAGE_OFFSET for address comparison.
--- arch/powerpc/kernel/head_8xx.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kernel/head_8xx.S +3 -3
@@ -41,12 +41,12 @@ #include "head_32.h" .macro compare_to_kernel_boundary scratch, addr -#if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000 +#if CONFIG_TASK_SIZE <= 0x80000000 && MODULES_VADDR >= 0x80000000 /* By simply checking Address >= 0x80000000, we know if its a kernel address */ not. \scratch, \addr #else rlwinm \scratch, \addr, 16, 0xfff8 - cmpli cr0, \scratch, PAGE_OFFSET@h + cmpli cr0, \scratch, TASK_SIZE@h #endif .endm
@@ -404,7 +404,7 @@ FixupDAR:/* Entry point for dcbx workaround. */ mfspr r10, SPRN_SRR0 mtspr SPRN_MD_EPN, r10 rlwinm r11, r10, 16, 0xfff8 - cmpli cr1, r11, PAGE_OFFSET@h + cmpli cr1, r11, TASK_SIZE@h mfspr r11, SPRN_M_TWB /* Get level 1 table */ blt+ cr1, 3f
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 198/634 powerpc/vdso: Inconditionally use CFUNC macro
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 65948b0e716a47382731889ee6bbb18642b8b003 ]
During merge of commit 4e991e3c16a3 ("powerpc: add CFUNC assembly label annotation") a fallback version of CFUNC macro was added at the last minute, so it can be used inconditionally.
--- arch/powerpc/kernel/vdso/gettimeofday.S | 4 ---- 1 file changed, 4 deletions(-)
arch/powerpc/kernel/vdso/gettimeofday.S +0 -4
@@ -38,11 +38,7 @@ .else addi r4, r5, VDSO_DATA_OFFSET .endif -#ifdef __powerpc64__ bl CFUNC(DOTSYM(\funct)) -#else - bl \funct -#endif PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1) #ifdef __powerpc64__ PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 199/634 drm/msm: Use a7xx family directly in gpu_state
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Connor Abbott <[email protected]>
[ Upstream commit db75ef03d72ea75515f5282fe8a4925ae8373fe1 ]
With a7xx, we need to import a new header for each new generation and switch to a different list of registers, instead of making backwards-compatible changes. Using the helpers inadvertently made a750 use the a740 list of registers, instead use the family directly to fix this.
Patchwork: https://patchwork.freedesktop.org/patch/607392/
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 41 ++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +20 -21
@@ -388,18 +388,18 @@ static void a7xx_get_debugbus_blocks(struct msm_gpu *gpu,const u32 *debugbus_blocks, *gbif_debugbus_blocks;int i; -if (adreno_is_a730 (adreno_gpu)) { +if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) { debugbus_blocks = gen7_0_0_debugbus_blocks; debugbus_blocks_count =ARRAY_SIZE (gen7_0_0_debugbus_blocks); gbif_debugbus_blocks = a7xx_gbif_debugbus_blocks; gbif_debugbus_blocks_count =ARRAY_SIZE (a7xx_gbif_debugbus_blocks); - }else if (adreno_is_a740_family (adreno_gpu)) { + }else if (adreno_gpu->info->family ==ADRENO_7XX_GEN2 ) { debugbus_blocks = gen7_2_0_debugbus_blocks; debugbus_blocks_count =ARRAY_SIZE (gen7_2_0_debugbus_blocks); gbif_debugbus_blocks = a7xx_gbif_debugbus_blocks; gbif_debugbus_blocks_count =ARRAY_SIZE (a7xx_gbif_debugbus_blocks); }else { -BUG_ON (!adreno_is_a750 (adreno_gpu)); +BUG_ON (adreno_gpu->info->family !=ADRENO_7XX_GEN3 ); debugbus_blocks = gen7_9_0_debugbus_blocks; debugbus_blocks_count =ARRAY_SIZE (gen7_9_0_debugbus_blocks); gbif_debugbus_blocks = gen7_9_0_gbif_debugbus_blocks;
@@ -509,7 +509,7 @@ static void a6xx_get_debugbus(struct msm_gpu *gpu,const struct a6xx_debugbus_block *cx_debugbus_blocks;if (adreno_is_a7xx (adreno_gpu)) { -BUG_ON (!(adreno_is_a730 (adreno_gpu) ||adreno_is_a740_family (adreno_gpu))); +BUG_ON (adreno_gpu->info->family >ADRENO_7XX_GEN3 ); cx_debugbus_blocks = a7xx_cx_debugbus_blocks; nr_cx_debugbus_blocks =ARRAY_SIZE (a7xx_cx_debugbus_blocks); }else {
@@ -660,11 +660,11 @@ static void a7xx_get_dbgahb_clusters(struct msm_gpu *gpu,const struct gen7_sptp_cluster_registers *dbgahb_clusters;unsigned dbgahb_clusters_size; -if (adreno_is_a730 (adreno_gpu)) { +if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) { dbgahb_clusters = gen7_0_0_sptp_clusters; dbgahb_clusters_size =ARRAY_SIZE (gen7_0_0_sptp_clusters); }else { -BUG_ON (!adreno_is_a740_family (adreno_gpu)); +BUG_ON (adreno_gpu->info->family >ADRENO_7XX_GEN3 ); dbgahb_clusters = gen7_2_0_sptp_clusters; dbgahb_clusters_size =ARRAY_SIZE (gen7_2_0_sptp_clusters); }
@@ -818,14 +818,14 @@ static void a7xx_get_clusters(struct msm_gpu *gpu,const struct gen7_cluster_registers *clusters;unsigned clusters_size; -if (adreno_is_a730 (adreno_gpu)) { +if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) { clusters = gen7_0_0_clusters; clusters_size =ARRAY_SIZE (gen7_0_0_clusters); - }else if (adreno_is_a740_family (adreno_gpu)) { + }else if (adreno_gpu->info->family ==ADRENO_7XX_GEN2 ) { clusters = gen7_2_0_clusters; clusters_size =ARRAY_SIZE (gen7_2_0_clusters); }else { -BUG_ON (!adreno_is_a750 (adreno_gpu)); +BUG_ON (adreno_gpu->info->family !=ADRENO_7XX_GEN3 ); clusters = gen7_9_0_clusters; clusters_size =ARRAY_SIZE (gen7_9_0_clusters); }
@@ -893,7 +893,7 @@ static void a7xx_get_shader_block(struct msm_gpu *gpu,if (WARN_ON (datasize >A6XX_CD_DATA_SIZE ))return ; -if (adreno_is_a730 (adreno_gpu)) { +if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) {gpu_rmw (gpu,REG_A7XX_SP_DBG_CNTL ,GENMASK (1 ,0 ),3 ); }
@@ -923,7 +923,7 @@ static void a7xx_get_shader_block(struct msm_gpu *gpu, datasize); out: -if (adreno_is_a730 (adreno_gpu)) { +if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) {gpu_rmw (gpu,REG_A7XX_SP_DBG_CNTL ,GENMASK (1 ,0 ),0 ); } }
@@ -956,14 +956,14 @@ static void a7xx_get_shaders(struct msm_gpu *gpu,unsigned num_shader_blocks;int i; -if (adreno_is_a730 (adreno_gpu)) { +if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) { shader_blocks = gen7_0_0_shader_blocks; num_shader_blocks =ARRAY_SIZE (gen7_0_0_shader_blocks); - }else if (adreno_is_a740_family (adreno_gpu)) { + }else if (adreno_gpu->info->family ==ADRENO_7XX_GEN2 ) { shader_blocks = gen7_2_0_shader_blocks; num_shader_blocks =ARRAY_SIZE (gen7_2_0_shader_blocks); }else { -BUG_ON (!adreno_is_a750 (adreno_gpu)); +BUG_ON (adreno_gpu->info->family !=ADRENO_7XX_GEN3 ); shader_blocks = gen7_9_0_shader_blocks; num_shader_blocks =ARRAY_SIZE (gen7_9_0_shader_blocks); }
@@ -1348,14 +1348,14 @@ static void a7xx_get_registers(struct msm_gpu *gpu,const u32 *pre_crashdumper_regs;const struct gen7_reg_list *reglist; -if (adreno_is_a730 (adreno_gpu)) { +if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) { reglist = gen7_0_0_reg_list; pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers; - }else if (adreno_is_a740_family (adreno_gpu)) { + }else if (adreno_gpu->info->family ==ADRENO_7XX_GEN2 ) { reglist = gen7_2_0_reg_list; pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers; }else { -BUG_ON (!adreno_is_a750 (adreno_gpu)); +BUG_ON (adreno_gpu->info->family !=ADRENO_7XX_GEN3 ); reglist = gen7_9_0_reg_list; pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers; }
@@ -1405,8 +1405,7 @@ static void a7xx_get_post_crashdumper_registers(struct msm_gpu *gpu,struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);const u32 *regs; -BUG_ON (!(adreno_is_a730 (adreno_gpu) ||adreno_is_a740_family (adreno_gpu) || -adreno_is_a750 (adreno_gpu))); +BUG_ON (adreno_gpu->info->family >ADRENO_7XX_GEN3 ); regs = gen7_0_0_post_crashdumper_registers; a7xx_get_ahb_gpu_registers(gpu,
@@ -1514,11 +1513,11 @@ static void a7xx_get_indexed_registers(struct msm_gpu *gpu,const struct a6xx_indexed_registers *indexed_regs;int i, indexed_count, mempool_count; -if (adreno_is_a730 (adreno_gpu) ||adreno_is_a740_family (adreno_gpu)) { +if (adreno_gpu->info->family <=ADRENO_7XX_GEN2 ) { indexed_regs = a7xx_indexed_reglist; indexed_count =ARRAY_SIZE (a7xx_indexed_reglist); }else { -BUG_ON (!adreno_is_a750 (adreno_gpu)); +BUG_ON (adreno_gpu->info->family !=ADRENO_7XX_GEN3 ); indexed_regs = gen7_9_0_cp_indexed_reg_list; indexed_count =ARRAY_SIZE (gen7_9_0_cp_indexed_reg_list); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 200/634 drm/msm: Dump correct dbgahb clusters on a750
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Connor Abbott <[email protected]>
[ Upstream commit d8c17d7aadc2463a395f9340f44c7c34399f1d48 ]
This was missed thanks to the family mixup fixed in the previous commit.
Patchwork: https://patchwork.freedesktop.org/patch/607393/
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +5 -2
@@ -663,10 +663,13 @@ static void a7xx_get_dbgahb_clusters(struct msm_gpu *gpu,if (adreno_gpu->info->family ==ADRENO_7XX_GEN1 ) { dbgahb_clusters = gen7_0_0_sptp_clusters; dbgahb_clusters_size =ARRAY_SIZE (gen7_0_0_sptp_clusters); - }else { -BUG_ON (adreno_gpu->info->family >ADRENO_7XX_GEN3 ); + }else if (adreno_gpu->info->family ==ADRENO_7XX_GEN2 ) { dbgahb_clusters = gen7_2_0_sptp_clusters; dbgahb_clusters_size =ARRAY_SIZE (gen7_2_0_sptp_clusters); + }else { +BUG_ON (adreno_gpu->info->family !=ADRENO_7XX_GEN3 ); + dbgahb_clusters = gen7_9_0_sptp_clusters; + dbgahb_clusters_size =ARRAY_SIZE (gen7_9_0_sptp_clusters); } a6xx_state->dbgahb_clusters = state_kcalloc(a6xx_state,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 201/634 drm/msm: Fix CP_BV_DRAW_STATE_ADDR name
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Connor Abbott <[email protected]>
[ Upstream commit a47cfb688d78217983c4a0051449aa88e2ff5ebb ]
This was missed because we weren't using the a750-specific indexed regs.
Patchwork: https://patchwork.freedesktop.org/patch/607394/
--- drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h +1 -1
@@ -1303,7 +1303,7 @@ static struct a6xx_indexed_registers gen7_9_0_cp_indexed_reg_list[] = { REG_A6XX_CP_ROQ_DBG_DATA, 0x00800}, {"CP_UCODE_DBG_DATA" ,REG_A6XX_CP_SQE_UCODE_DBG_ADDR , REG_A6XX_CP_SQE_UCODE_DBG_DATA, 0x08000}, - { "CP_BV_SQE_STAT_ADDR", REG_A7XX_CP_BV_DRAW_STATE_ADDR, + { "CP_BV_DRAW_STATE_ADDR", REG_A7XX_CP_BV_DRAW_STATE_ADDR, REG_A7XX_CP_BV_DRAW_STATE_DATA, 0x00200}, { "CP_BV_ROQ_DBG_ADDR", REG_A7XX_CP_BV_ROQ_DBG_ADDR, REG_A7XX_CP_BV_ROQ_DBG_DATA, 0x00800},
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 202/634 drm/msm: Fix incorrect file name output in adreno_request_fw()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mishin <[email protected]>
[ Upstream commit e19366911340c2313a1abbb09c54eaf9bdea4f58 ]
In adreno_request_fw() when debugging information is printed to the log after firmware load, an incorrect filename is printed. 'newname' is used instead of 'fwname', so prefix "qcom/" is being added to filename. Looks like "copy-paste" mistake.
Fix this mistake by replacing 'newname' with 'fwname'.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Patchwork: https://patchwork.freedesktop.org/patch/602382/
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
@@ -475,7 +475,7 @@ adreno_request_fw(struct adreno_gpu *adreno_gpu, const char *fwname) ret =request_firmware_direct (&fw, fwname, drm->dev);if (!ret) {DRM_DEV_INFO (drm->dev,"loaded %s from legacy location\n" , - newname); + fwname); adreno_gpu->fwloc =FW_LOCATION_LEGACY ; goto out; }else if (adreno_gpu->fwloc !=FW_LOCATION_UNKNOWN ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 203/634 drm/msm/a5xx: disable preemption in submits by default
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit db9dec2db76146d65e1cfbb6afb2e2bd5dab67f8 ]
Fine grain preemption (switching from/to points within submits) requires extra handling in command stream of those submits, especially when rendering with tiling (using GMEM). However this handling is missing at this point in mesa (and always was). For this reason we get random GPU faults and hangs if more than one priority level is used because local preemption is enabled prior to executing command stream from submit.
With that said it was ahead of time to enable local preemption by default considering the fact that even on downstream kernel it is only enabled if requested via UAPI.
Patchwork: https://patchwork.freedesktop.org/patch/612041/
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +6 -2
@@ -150,9 +150,13 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)OUT_PKT7 (ring,CP_SET_PROTECTED_MODE ,1 );OUT_RING (ring,1 ); -/* Enable local preemption for finegrain preemption */ +/* +* Disable local preemption by default because it requires +* user-space to be aware of it and provide additional handling +* to restore rendering state or do various flushes on switch. +*/ OUT_PKT7 (ring,CP_PREEMPT_ENABLE_LOCAL ,1 ); -OUT_RING (ring,0x1 ); +OUT_RING (ring,0x0 );/* Allow CP_CONTEXT_SWITCH_YIELD packets in the IB2 */ OUT_PKT7 (ring,CP_YIELD_ENABLE ,1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 204/634 drm/msm/a5xx: properly clear preemption records on resume
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit 64fd6d01a52904bdbda0ce810a45a428c995a4ca ]
Two fields of preempt_record which are used by CP aren't reset on
resume: "data" and "info". This is the reason behind faults which happen when we try to switch to the ring that was active last before suspend. In addition those faults can't be recovered from because we use suspend and resume to do so (keeping values of those fields again).
Patchwork: https://patchwork.freedesktop.org/patch/612043/
--- drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +2 -0
@@ -204,6 +204,8 @@ void a5xx_preempt_hw_init(struct msm_gpu *gpu)return ;for (i =0 ; i < gpu->nr_rings; i++) { + a5xx_gpu->preempt[i]->data =0 ; + a5xx_gpu->preempt[i]->info =0 ; a5xx_gpu->preempt[i]->wptr =0 ; a5xx_gpu->preempt[i]->rptr =0 ; a5xx_gpu->preempt[i]->rbase = gpu->rb[i]->iova;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 205/634 drm/msm/a5xx: fix races in preemption evaluation stage
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit ce050f307ad93bcc5958d0dd35fc276fd394d274 ]
On A5XX GPUs when preemption is used it's invietable to enter a soft lock-up state in which GPU is stuck at empty ring-buffer doing nothing. This appears as full UI lockup and not detected as GPU hang (because it's not). This happens due to not triggering preemption when it was needed. Sometimes this state can be recovered by some new submit but generally it won't happen because applications are waiting for old submits to retire.
One of the reasons why this happens is a race between a5xx_submit and a5xx_preempt_trigger called from IRQ during submit retire. Former thread updates ring->cur of previously empty and not current ring right after latter checks it for emptiness. Then both threads can just exit because for first one preempt_state wasn't NONE yet and for second one all rings appeared to be empty.
To prevent such situations from happening we need to establish guarantee for preempt_trigger to make decision after each submit or retire. To implement this we serialize preemption initiation using spinlock. If switch is already in progress we need to re-trigger preemption when it finishes.
Patchwork: https://patchwork.freedesktop.org/patch/612045/
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 24 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -0
@@ -36,6 +36,7 @@ struct a5xx_gpu {uint64_t preempt_iova[MSM_GPU_MAX_RINGS ];atomic_t preempt_state; +spinlock_t preempt_start_lock;struct timer_list preempt_timer;struct drm_gem_object *shadow_bo;
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +22 -2
@@ -97,12 +97,19 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)if (gpu->nr_rings ==1 )return ; +/* +* Serialize preemption start to ensure that we always make +* decision on latest state. Otherwise we can get stuck in +* lower priority or empty ring. +*/ +spin_lock_irqsave (&a5xx_gpu->preempt_start_lock, flags); +/* * Try to start preemption by moving from NONE to START. If * unsuccessful, a preemption is already in flight */ if (!try_preempt_state (a5xx_gpu,PREEMPT_NONE ,PREEMPT_START )) -return ; + goto out;/* Get the next ring to preempt to */ ring =get_next_ring (gpu);
@@ -127,9 +134,11 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)set_preempt_state (a5xx_gpu,PREEMPT_ABORT );update_wptr (gpu, a5xx_gpu->cur_ring);set_preempt_state (a5xx_gpu,PREEMPT_NONE ); -return ; + goto out; } +spin_unlock_irqrestore (&a5xx_gpu->preempt_start_lock, flags); +/* Make sure the wptr doesn't update while we're in motion */ spin_lock_irqsave (&ring->preempt_lock, flags); a5xx_gpu->preempt[ring->id]->wptr =get_wptr (ring);
@@ -152,6 +161,10 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)/* And actually start the preemption */ gpu_write (gpu,REG_A5XX_CP_CONTEXT_SWITCH_CNTL ,1 ); +return ; + +out: +spin_unlock_irqrestore (&a5xx_gpu->preempt_start_lock, flags); }void a5xx_preempt_irq (struct msm_gpu *gpu)
@@ -188,6 +201,12 @@ void a5xx_preempt_irq(struct msm_gpu *gpu)update_wptr (gpu, a5xx_gpu->cur_ring);set_preempt_state (a5xx_gpu,PREEMPT_NONE ); + +/* +* Try to trigger preemption again in case there was a submit or +* retire during ring switch +*/ +a5xx_preempt_trigger (gpu); }void a5xx_preempt_hw_init (struct msm_gpu *gpu)
@@ -300,5 +319,6 @@ void a5xx_preempt_init(struct msm_gpu *gpu) } } +spin_lock_init (&a5xx_gpu->preempt_start_lock);timer_setup (&a5xx_gpu->preempt_timer, a5xx_preempt_timer,0 ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 206/634 drm/msm/a5xx: workaround early ring-buffer emptiness check
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Lypak <[email protected]>
[ Upstream commit a30f9f65b5ac82d4390548c32ed9c7f05de7ddf5 ]
There is another cause for soft lock-up of GPU in empty ring-buffer:
race between GPU executing last commands and CPU checking ring for emptiness. On GPU side IRQ for retire is triggered by CACHE_FLUSH_TS event and RPTR shadow (which is used to check ring emptiness) is updated a bit later from CP_CONTEXT_SWITCH_YIELD. Thus if GPU is executing its last commands slow enough or we check that ring too fast we will miss a chance to trigger switch to lower priority ring because current ring isn't empty just yet. This can escalate to lock-up situation described in previous patch.
To work-around this issue we keep track of last submit sequence number for each ring and compare it with one written to memptrs from GPU during execution of CACHE_FLUSH_TS event.
Patchwork: https://patchwork.freedesktop.org/patch/612047/
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++++ drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 4 ++++ 3 files changed, 9 insertions(+)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +4 -0
@@ -65,6 +65,8 @@ void a5xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring,static void a5xx_submit_in_rb (struct msm_gpu *gpu,struct msm_gem_submit *submit) { +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a5xx_gpu *a5xx_gpu =to_a5xx_gpu (adreno_gpu);struct msm_ringbuffer *ring = submit->ring;struct drm_gem_object *obj;uint32_t *ptr, dwords;
@@ -109,6 +111,7 @@ static void a5xx_submit_in_rb(struct msm_gpu *gpu, struct msm_gem_submit *submit } } + a5xx_gpu->last_seqno[ring->id] = submit->seqno;a5xx_flush (gpu, ring, true);a5xx_preempt_trigger (gpu);
@@ -210,6 +213,7 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)/* Write the fence to the scratch register */ OUT_PKT4 (ring,REG_A5XX_CP_SCRATCH_REG (2 ),1 );OUT_RING (ring, submit->seqno); + a5xx_gpu->last_seqno[ring->id] = submit->seqno;/* * Execute a CACHE_FLUSH_TS event. This will ensure that the
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -0
@@ -34,6 +34,7 @@ struct a5xx_gpu {struct drm_gem_object *preempt_counters_bo[MSM_GPU_MAX_RINGS ];struct a5xx_preempt_record *preempt[MSM_GPU_MAX_RINGS ];uint64_t preempt_iova[MSM_GPU_MAX_RINGS ]; +uint32_t last_seqno[MSM_GPU_MAX_RINGS ];atomic_t preempt_state;spinlock_t preempt_start_lock;
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +4 -0
@@ -55,6 +55,8 @@ static inline void update_wptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)/* Return the highest priority ringbuffer with something in it */ static struct msm_ringbuffer *get_next_ring (struct msm_gpu *gpu) { +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a5xx_gpu *a5xx_gpu =to_a5xx_gpu (adreno_gpu);unsigned long flags;int i;
@@ -64,6 +66,8 @@ static struct msm_ringbuffer *get_next_ring(struct msm_gpu *gpu)spin_lock_irqsave (&ring->preempt_lock, flags); empty = (get_wptr (ring) == gpu->funcs->get_rptr (gpu, ring)); +if (!empty && ring == a5xx_gpu->cur_ring) + empty = ring->memptrs->fence == a5xx_gpu->last_seqno[i];spin_unlock_irqrestore (&ring->preempt_lock, flags);if (!empty)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 207/634 ipmi: docs: dont advertise deprecated sysfs entries
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 64dce81f8c373c681e62d5ffe0397c45a35d48a2 ]
"i2c-adapter" class entries are deprecated since 2009. Switch to the proper location.
Message-Id: <[email protected]>
--- Documentation/driver-api/ipmi.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/driver-api/ipmi.rst +1 -1
@@ -540,7 +540,7 @@ at module load time (for a module) with:: alerts_broken The addresses are normal I2C addresses. The adapter is the string -name of the adapter, as shown in /sys/class/i2c-adapter/i2c-<n>/name. +name of the adapter, as shown in /sys/bus/i2c/devices/i2c-<n>/name. It is *NOT* i2c-<n> itself. Also, the comparison is done ignoring spaces, so if the name is "This is an I2C chip" you can say adapter_name=ThisisanI2cchip. This is because it's hard to pass in
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 208/634 drm/msm/dp: enable widebus on all relevant chipsets
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhinav Kumar <[email protected]>
[ Upstream commit c7c412202623951dcfc22316f5255fd84fd56186 ]
Hardware document indicates that widebus is recommended on DP on all MDSS chipsets starting version 5.x.x and above.
Follow the guideline and mark widebus support on all relevant chipsets for DP.
Patchwork: https://patchwork.freedesktop.org/patch/606556/
--- drivers/gpu/drm/msm/dp/dp_display.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +5 -5
@@ -119,7 +119,7 @@ struct msm_dp_desc { };static const struct msm_dp_desc sc7180_dp_descs[] = { - { .io_start =0x0ae90000 , .id =MSM_DP_CONTROLLER_0 }, + { .io_start =0x0ae90000 , .id =MSM_DP_CONTROLLER_0 , .wide_bus_supported = true }, {} };
@@ -130,9 +130,9 @@ static const struct msm_dp_desc sc7280_dp_descs[] = { };static const struct msm_dp_desc sc8180x_dp_descs[] = { - { .io_start =0x0ae90000 , .id =MSM_DP_CONTROLLER_0 }, - { .io_start =0x0ae98000 , .id =MSM_DP_CONTROLLER_1 }, - { .io_start =0x0ae9a000 , .id =MSM_DP_CONTROLLER_2 }, + { .io_start =0x0ae90000 , .id =MSM_DP_CONTROLLER_0 , .wide_bus_supported = true }, + { .io_start =0x0ae98000 , .id =MSM_DP_CONTROLLER_1 , .wide_bus_supported = true }, + { .io_start =0x0ae9a000 , .id =MSM_DP_CONTROLLER_2 , .wide_bus_supported = true }, {} };
@@ -149,7 +149,7 @@ static const struct msm_dp_desc sc8280xp_dp_descs[] = { };static const struct msm_dp_desc sm8650_dp_descs[] = { - { .io_start =0x0af54000 , .id =MSM_DP_CONTROLLER_0 }, + { .io_start =0x0af54000 , .id =MSM_DP_CONTROLLER_0 , .wide_bus_supported = true }, {} };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 209/634 drm/msm/dsi: correct programming sequence for SM8350 / SM8450
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 1328cb7c34bf6d056df9ff694ee5194537548258 ]
According to the display-drivers, 5nm DSI PLL (v4.2, v4.3) have different boundaries for pll_clock_inverters programming. Follow the vendor code and use correct values.
Patchwork: https://patchwork.freedesktop.org/patch/606947/
--- drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +11 -1
@@ -135,7 +135,7 @@ static void dsi_pll_calc_dec_frac(struct dsi_pll_7nm *pll, struct dsi_pll_config config->pll_clock_inverters =0x00 ; else config->pll_clock_inverters = 0x40; - }else { + }else if (pll->phy->cfg->quirks &DSI_PHY_7NM_QUIRK_V4_1 ) {if (pll_freq <=1000000000ULL ) config->pll_clock_inverters =0xa0 ;else if (pll_freq <=2500000000ULL )
@@ -144,6 +144,16 @@ static void dsi_pll_calc_dec_frac(struct dsi_pll_7nm *pll, struct dsi_pll_config config->pll_clock_inverters =0x00 ; else config->pll_clock_inverters = 0x40; + }else { +/* 4.2, 4.3 */ +if (pll_freq <=1000000000ULL ) + config->pll_clock_inverters =0xa0 ; +else if (pll_freq <=2500000000ULL ) + config->pll_clock_inverters =0x20 ; +else if (pll_freq <=3500000000ULL ) + config->pll_clock_inverters =0x00 ; +else + config->pll_clock_inverters =0x40 ; } config->decimal_div_start = dec;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 210/634 drm/msm: fix %s null argument error
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sherry Yang <[email protected]>
[ Upstream commit 25b85075150fe8adddb096db8a4b950353045ee1 ]
The following build error was triggered because of NULL string argument:
BUILDSTDERR: drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c: In function 'mdp5_smp_dump': BUILDSTDERR: drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c:352:51: error: '%s' directive argument is null [-Werror=format-overflow=] BUILDSTDERR: 352 | drm_printf(p, "%s:%d\t%d\t%s\n", BUILDSTDERR: | ^~ BUILDSTDERR: drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c:352:51: error: '%s' directive argument is null [-Werror=format-overflow=]
This happens from the commit a61ddb4393ad ("drm: enable (most) W=1 warnings by default across the subsystem"). Using "(null)" instead to fix it.
Patchwork: https://patchwork.freedesktop.org/patch/611071/
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c +1 -1
@@ -351,7 +351,7 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p,drm_printf (p,"%s:%d\t%d\t%s\n" ,pipe2name (pipe), j, inuse, - plane ? plane->name :NULL ); + plane ? plane->name :"(null)" ); total += inuse; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 211/634 platform/x86: ideapad-laptop: Make the scope_guard() clear of its scope
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit a093cb667c3ff5eadd4b23ddf996d9ccae9b7ac6 ]
First of all, it's a bit counterintuitive to have something like
int err; ... scoped_guard(...) err = foo(...); if (err) return err;
Second, with a particular kernel configuration and compiler version in one of such cases the objtool is not happy:
ideapad-laptop.o: warning: objtool: .text.fan_mode_show: unexpected end of section
I'm not an expert on all this, but the theory is that compiler and linker in this case can't understand that 'result' variable will be always initialized as long as no error has been returned. Assigning 'result' to a dummy value helps with this. Note, that fixing the scoped_guard() scope (as per above) does not make issue gone.
That said, assign dummy value and make the scope_guard() clear of its scope. For the sake of consistency do it in the entire file.
--- drivers/platform/x86/ideapad-laptop.c | 48 +++++++++++++++------------ 1 file changed, 27 insertions(+), 21 deletions(-)
drivers/platform/x86/ideapad-laptop.c +27 -21
@@ -422,13 +422,14 @@ static ssize_t camera_power_show(struct device *dev, char *buf) {struct ideapad_private *priv =dev_get_drvdata (dev); -unsigned long result; +unsigned long result =0 ;int err; -scoped_guard (mutex, &priv->vpc_mutex) + scoped_guard(mutex, &priv->vpc_mutex) { err =read_ec_data (priv->adev->handle,VPCCMD_R_CAMERA , &result); -if (err) -return err; +if (err) +return err; + }return sysfs_emit (buf,"%d\n" , !!result); }
@@ -445,10 +446,11 @@ static ssize_t camera_power_store(struct device *dev,if (err)return err; -scoped_guard (mutex, &priv->vpc_mutex) + scoped_guard(mutex, &priv->vpc_mutex) { err =write_ec_cmd (priv->adev->handle,VPCCMD_W_CAMERA , state); -if (err) -return err; +if (err) +return err; + }return count; }
@@ -496,13 +498,14 @@ static ssize_t fan_mode_show(struct device *dev, char *buf) {struct ideapad_private *priv =dev_get_drvdata (dev); -unsigned long result; +unsigned long result =0 ;int err; -scoped_guard (mutex, &priv->vpc_mutex) + scoped_guard(mutex, &priv->vpc_mutex) { err =read_ec_data (priv->adev->handle,VPCCMD_R_FAN , &result); -if (err) -return err; +if (err) +return err; + }return sysfs_emit (buf,"%lu\n" , result); }
@@ -522,10 +525,11 @@ static ssize_t fan_mode_store(struct device *dev,if (state >4 || state ==3 )return -EINVAL ; -scoped_guard (mutex, &priv->vpc_mutex) + scoped_guard(mutex, &priv->vpc_mutex) { err =write_ec_cmd (priv->adev->handle,VPCCMD_W_FAN , state); -if (err) -return err; +if (err) +return err; + }return count; }
@@ -605,13 +609,14 @@ static ssize_t touchpad_show(struct device *dev, char *buf) {struct ideapad_private *priv =dev_get_drvdata (dev); -unsigned long result; +unsigned long result =0 ;int err; -scoped_guard (mutex, &priv->vpc_mutex) + scoped_guard(mutex, &priv->vpc_mutex) { err =read_ec_data (priv->adev->handle,VPCCMD_R_TOUCHPAD , &result); -if (err) -return err; +if (err) +return err; + } priv->r_touchpad_val = result;
@@ -630,10 +635,11 @@ static ssize_t touchpad_store(struct device *dev,if (err)return err; -scoped_guard (mutex, &priv->vpc_mutex) + scoped_guard(mutex, &priv->vpc_mutex) { err =write_ec_cmd (priv->adev->handle,VPCCMD_W_TOUCHPAD , state); -if (err) -return err; +if (err) +return err; + } priv->r_touchpad_val = state;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 212/634 kselftest: dt: Ignore nodes that have ancestors disabled
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 05144ab7b7eaf531fc728fcb79dcf36b621ff42d ]
Filter out nodes that have one of its ancestors disabled as they aren't expected to probe.
This removes the following false-positive failures on the sc7180-trogdor-lazor-limozeen-nots-r5 platform:
/soc@0/geniqup@8c0000/i2c@894000/proximity@28 /soc@0/geniqup@ac0000/spi@a90000/ec@0 /soc@0/remoteproc@62400000/glink-edge/apr /soc@0/remoteproc@62400000/glink-edge/apr/service@3 /soc@0/remoteproc@62400000/glink-edge/apr/service@4 /soc@0/remoteproc@62400000/glink-edge/apr/service@4/clock-controller /soc@0/remoteproc@62400000/glink-edge/apr/service@4/dais /soc@0/remoteproc@62400000/glink-edge/apr/service@7 /soc@0/remoteproc@62400000/glink-edge/apr/service@7/dais /soc@0/remoteproc@62400000/glink-edge/apr/service@8 /soc@0/remoteproc@62400000/glink-edge/apr/service@8/routing /soc@0/remoteproc@62400000/glink-edge/fastrpc /soc@0/remoteproc@62400000/glink-edge/fastrpc/compute-cb@3 /soc@0/remoteproc@62400000/glink-edge/fastrpc/compute-cb@4 /soc@0/remoteproc@62400000/glink-edge/fastrpc/compute-cb@5 /soc@0/spmi@c440000/pmic@0/pon@800/pwrkey
--- .../testing/selftests/dt/test_unprobed_devices.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
tools/testing/selftests/dt/test_unprobed_devices.sh +14 -1
@@ -34,8 +34,21 @@ nodes_compatible=$( # Check if node is available if [[ -e "${node}"/status ]]; then status=$(tr -d '\000' < "${node}"/status) - [[ "${status}" != "okay" && "${status}" != "ok" ]] && continue + if [[ "${status}" != "okay" && "${status}" != "ok" ]]; then + if [ -n "${disabled_nodes_regex}" ]; then + disabled_nodes_regex="${disabled_nodes_regex}|${node}" + else + disabled_nodes_regex="${node}" + fi + continue + fi fi + + # Ignore this node if one of its ancestors was disabled + if [ -n "${disabled_nodes_regex}" ]; then + echo "${node}" | grep -q -E "${disabled_nodes_regex}" && continue + fi + echo "${node}" | sed -e 's|\/proc\/device-tree||' done | sort )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 213/634 drivers:drm:exynos_drm_gsc:Fix wrong assignment in gsc_bind()
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuesong Li <[email protected]>
[ Upstream commit 94ebc3d3235c5c516f67315059ce657e5090e94b ]
cocci reported a double assignment problem. Upon reviewing previous commits, it appears this may actually be an incorrect assignment.
--- drivers/gpu/drm/exynos/exynos_drm_gsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_gsc.c +1 -1
@@ -1174,7 +1174,7 @@ static int gsc_bind(struct device *dev, struct device *master, void *data)struct exynos_drm_ipp *ipp = &ctx->ipp; ctx->drm_dev = drm_dev; - ctx->drm_dev = drm_dev; + ipp->drm_dev = drm_dev;exynos_drm_register_dma (drm_dev, dev, &ctx->dma_priv); exynos_drm_ipp_register(dev, ipp, &ipp_funcs,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 214/634 drm/amdgpu: fix invalid fence handling in amdgpu_vm_tlb_flush
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lang Yu <[email protected]>
[ Upstream commit 4453808d9eab0461dea338e89372ffc4a3c50acc ]
CPU based update doesn't produce a fence, handle such cases properly.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -2
@@ -902,10 +902,12 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params, {struct amdgpu_vm *vm = params->vm; -if (!fence || !*fence) + tlb_cb->vm = vm; +if (!fence || !*fence) { +amdgpu_vm_tlb_seq_cb (NULL , &tlb_cb->cb);return ; + } - tlb_cb->vm = vm;if (!dma_fence_add_callback (*fence, &tlb_cb->cb, amdgpu_vm_tlb_seq_cb)) {dma_fence_put (vm->last_tlb_flush);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 215/634 xen: use correct end address of kernel for conflict checking
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit fac1bceeeb04886fc2ee952672e6e6c85ce41dca ]
When running as a Xen PV dom0 the kernel is loaded by the hypervisor using a different memory map than that of the host. In order to minimize the required changes in the kernel, the kernel adapts its memory map to that of the host. In order to do that it is checking for conflicts of its load address with the host memory map.
Unfortunately the tested memory range does not include the .brk area, which might result in crashes or memory corruption when this area does conflict with the memory map of the host.
Fix the test by using the _end label instead of __bss_stop.
--- arch/x86/xen/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/setup.c +1 -1
@@ -825,7 +825,7 @@ char * __init xen_memory_setup(void)* to relocating (and even reusing) pages with kernel text or data. */ if (xen_is_e820_reserved (__pa_symbol (_text), -__pa_symbol (__bss_stop) -__pa_symbol (_text))) { +__pa_symbol (_end) -__pa_symbol (_text))) {xen_raw_console_write ("Xen hypervisor allocated kernel memory conflicts with E820 map\n" );BUG (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 216/634 HID: wacom: Support sequence numbers smaller than 16-bit
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gerecke <[email protected]>
[ Upstream commit 359673ea3a203611b4f6d0f28922a4b9d2cfbcc8 ]
The current dropped packet reporting assumes that all sequence numbers are 16 bits in length. This results in misleading "Dropped" messages if the hardware uses fewer bits. For example, if a tablet uses only 8 bits to store its sequence number, once it rolls over from 255 -> 0, the driver will still be expecting a packet "256". This patch adjusts the logic to reset the next expected packet to logical_minimum whenever it overflows beyond logical_maximum.
--- drivers/hid/wacom_wac.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +7 -2
@@ -2492,9 +2492,14 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.barrelswitch3 = value;return ;case WACOM_HID_WD_SEQUENCENUMBER : -if (wacom_wac->hid_data.sequence_number != value) -hid_warn (hdev,"Dropped %hu packets" , (unsigned short )(value - wacom_wac->hid_data.sequence_number)); +if (wacom_wac->hid_data.sequence_number != value) { +int sequence_size = field->logical_maximum - field->logical_minimum +1 ; +int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size; +hid_warn (hdev,"Dropped %d packets" , drop_count); + } wacom_wac->hid_data.sequence_number = value +1 ; +if (wacom_wac->hid_data.sequence_number > field->logical_maximum) + wacom_wac->hid_data.sequence_number = field->logical_minimum;return ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 217/634 HID: wacom: Do not warn about dropped packets for first packet
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gerecke <[email protected]>
[ Upstream commit 84aecf2d251a3359bc78b7c8e58f54b9fc966e89 ]
The driver currently assumes that the first sequence number it will see is going to be 0. This is not a realiable assumption and can break if, for example, the tablet has already been running for some time prior to the kernel driver connecting to the device. This commit initializes the expected sequence number to -1 and will only print the "Dropped" warning the it has been updated to a non-negative value.
--- drivers/hid/wacom_wac.c | 6 +++++- drivers/hid/wacom_wac.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +5 -1
@@ -2368,6 +2368,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,wacom_map_usage (input, usage, field,EV_KEY ,BTN_STYLUS3 ,0 ); features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3 ;break ; +case WACOM_HID_WD_SEQUENCENUMBER : + wacom_wac->hid_data.sequence_number =-1 ; +break ; } }
@@ -2492,7 +2495,8 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.barrelswitch3 = value;return ;case WACOM_HID_WD_SEQUENCENUMBER : -if (wacom_wac->hid_data.sequence_number != value) { +if (wacom_wac->hid_data.sequence_number != value && + wacom_wac->hid_data.sequence_number >=0 ) {int sequence_size = field->logical_maximum - field->logical_minimum +1 ;int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size;hid_warn (hdev,"Dropped %d packets" , drop_count);
drivers/hid/wacom_wac.h +1 -1
@@ -324,7 +324,7 @@ struct hid_data {int bat_connected;int ps_connected;bool pad_input_event_flag; -unsigned short sequence_number; +int sequence_number;ktime_t time_delayed; };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 218/634 ata: libata: Clear DID_TIME_OUT for ATA PT commands with sense data
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit e5dd410acb34c7341a0a93b429dcf3dabf9e3323 ]
When ata_qc_complete() schedules a command for EH using ata_qc_schedule_eh(), blk_abort_request() will be called, which leads to req->q->mq_ops->timeout() / scsi_timeout() being called.
scsi_timeout(), if the LLDD has no abort handler (libata has no abort handler), will set host byte to DID_TIME_OUT, and then call scsi_eh_scmd_add() to add the command to EH.
Thus, when commands first enter libata's EH strategy_handler, all the commands that have been added to EH will have DID_TIME_OUT set.
libata has its own flag (AC_ERR_TIMEOUT), that it sets for commands that have not received a completion at the time of entering EH.
Thus, libata doesn't really care about DID_TIME_OUT at all, and currently clears the host byte at the end of EH, in ata_scsi_qc_complete(), before scsi_eh_finish_cmd() is called.
However, this clearing in ata_scsi_qc_complete() is currently only done for commands that are not ATA passthrough commands.
Since the host byte is visible in the completion that we return to user space for ATA passthrough commands, for ATA passthrough commands that got completed via EH (commands with sense data), the user will incorrectly see:
ATA pass-through(16): transport error: Host_status=0x03 [DID_TIME_OUT]
Fix this by moving the clearing of the host byte (which is currently only done for commands that are not ATA passthrough commands) from ata_scsi_qc_complete() to the start of EH (regardless if the command is ATA passthrough or not).
While at it, use the proper helper function to clear the host byte, rather than open coding the clearing.
This will make sure that we:
-Correctly clear DID_TIME_OUT for both ATA passthrough commands and
commands that are not ATA passthrough commands.
-Do not needlessly clear the host byte for commands that did not go via EH.
ata_scsi_qc_complete() is called both for commands that are completed normally (without going via EH), and for commands that went via EH, however, only commands that went via EH will have DID_TIME_OUT set.
--- drivers/ata/libata-eh.c | 8 ++++++++ drivers/ata/libata-scsi.c | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/ata/libata-eh.c +8 -0
@@ -630,6 +630,14 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,list_for_each_entry_safe (scmd, tmp, eh_work_q, eh_entry) {struct ata_queued_cmd *qc; +/* +* If the scmd was added to EH, via ata_qc_schedule_eh() -> +* scsi_timeout() -> scsi_eh_scmd_add(), scsi_timeout() will +* have set DID_TIME_OUT (since libata does not have an abort +* handler). Thus, to clear DID_TIME_OUT, clear the host byte. +*/ +set_host_byte (scmd,DID_OK ); +ata_qc_for_each_raw (ap, qc, i) {if (qc->flags &ATA_QCFLAG_ACTIVE && qc->scsicmd == scmd)
drivers/ata/libata-scsi.c +0 -3
@@ -1693,9 +1693,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)set_status_byte (qc->scsicmd,SAM_STAT_CHECK_CONDITION ); }else if (is_error && !have_sense) {ata_gen_ata_sense (qc); - }else { -/* Keep the SCSI ML and status byte, clear host byte. */ - cmd->result &=0x0000ffff ; }ata_qc_done (qc);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 219/634 minmax: avoid overly complex min()/max() macro arguments in xen
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit e8432ac802a028eaee6b1e86383d7cd8e9fb8431 ]
We have some very fancy min/max macros that have tons of sanity checking to warn about mixed signedness etc.
This is all things that a sane compiler should warn about, but there are no sane compiler interfaces for this, and '-Wsign-compare' is broken [1] and not useful.
So then we compensate (some would say over-compensate) by doing the checks manually with some truly horrid macro games.
And no, we can't just use __builtin_types_compatible_p(), because the whole question of "does it make sense to compare these two values" is a lot more complicated than that.
For example, it makes a ton of sense to compare unsigned values with simple constants like "5", even if that is indeed a signed type. So we have these very strange macros to try to make sensible type checking decisions on the arguments to 'min()' and 'max()'.
But that can cause enormous code expansion if the min()/max() macros are used with complicated expressions, and particularly if you nest these things so that you get the first big expansion then expanded again.
The xen setup.c file ended up ballooning to over 50MB of preprocessed noise that takes 15s to compile (obviously depending on the build host), largely due to one single line.
So let's split that one single line to just be simpler. I think it ends up being more legible to humans too at the same time. Now that single file compiles in under a second.
Stable-dep-of: be35d91c8880 ("xen: tolerate ACPI NVS memory overlapping with Xen allocated memory")
--- arch/x86/xen/setup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/xen/setup.c +3 -2
@@ -691,6 +691,7 @@ char * __init xen_memory_setup(void)struct xen_memory_map memmap;unsigned long max_pages;unsigned long extra_pages =0 ; +unsigned long maxmem_pages;int i;int op;
@@ -762,8 +763,8 @@ char * __init xen_memory_setup(void)* Make sure we have no memory above max_pages, as this area * isn't handled by the p2m management. */ - extra_pages =min3 (EXTRA_MEM_RATIO *min (max_pfn,PFN_DOWN (MAXMEM )), - extra_pages, max_pages - max_pfn); + maxmem_pages =EXTRA_MEM_RATIO *min (max_pfn,PFN_DOWN (MAXMEM )); + extra_pages =min3 (maxmem_pages, extra_pages, max_pages - max_pfn); i =0 ; addr = xen_e820_table.entries[0 ].addr; size = xen_e820_table.entries[0 ].size;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 220/634 xen: introduce generic helper checking for memory map conflicts
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit ba88829706e2c5b7238638fc2b0713edf596495e ]
When booting as a Xen PV dom0 the memory layout of the dom0 is modified to match that of the host, as this requires less changes in the kernel for supporting Xen.
There are some cases, though, which are problematic, as it is the Xen hypervisor selecting the kernel's load address plus some other data, which might conflict with the host's memory map.
These conflicts are detected at boot time and result in a boot error. In order to support handling at least some of these conflicts in future, introduce a generic helper function which will later gain the ability to adapt the memory layout when possible.
Add the missing check for the xen_start_info area.
Note that possible p2m map and initrd memory conflicts are handled already by copying the data to memory areas not conflicting with the memory map. The initial stack allocated by Xen doesn't need to be checked, as early boot code is switching to the statically allocated initial kernel stack. Initial page tables and the kernel itself will be handled later.
Stable-dep-of: be35d91c8880 ("xen: tolerate ACPI NVS memory overlapping with Xen allocated memory")
--- arch/x86/xen/mmu_pv.c | 5 +---- arch/x86/xen/setup.c | 34 ++++++++++++++++++++++++++++------ arch/x86/xen/xen-ops.h | 3 ++- 3 files changed, 31 insertions(+), 11 deletions(-)
arch/x86/xen/mmu_pv.c +1 -4
@@ -2019,10 +2019,7 @@ void __init xen_reserve_special_pages(void)void __init xen_pt_check_e820 (void ) { -if (xen_is_e820_reserved (xen_pt_base, xen_pt_size)) { -xen_raw_console_write ("Xen hypervisor allocated page table memory conflicts with E820 map\n" ); -BUG (); - } +xen_chk_is_e820_usable (xen_pt_base, xen_pt_size,"page table" ); } static unsigned char dummy_mapping[PAGE_SIZE] __page_aligned_bss;
arch/x86/xen/setup.c +28 -6
@@ -568,7 +568,7 @@ static void __init xen_ignore_unusable(void) } } -bool __init xen_is_e820_reserved (phys_addr_t start,phys_addr_t size) +static bool __init xen_is_e820_reserved (phys_addr_t start,phys_addr_t size) {struct e820_entry *entry;unsigned mapcnt;
@@ -625,6 +625,23 @@ phys_addr_t __init xen_find_free_area(phys_addr_t size)return 0 ; } +/* +* Check for an area in physical memory to be usable for non-movable purposes. +* An area is considered to usable if the used E820 map lists it to be RAM. +* In case the area is not usable, crash the system with an error message. +*/ +void __init xen_chk_is_e820_usable (phys_addr_t start,phys_addr_t size, +const char *component) +{ +if (!xen_is_e820_reserved (start, size)) +return ; + +xen_raw_console_write ("Xen hypervisor allocated " ); +xen_raw_console_write (component); +xen_raw_console_write (" memory conflicts with E820 map\n" ); +BUG (); +} +/* * Like memcpy, but with physical addresses for dest and src. */
@@ -825,11 +842,16 @@ char * __init xen_memory_setup(void)* Failing now is better than running into weird problems later due * to relocating (and even reusing) pages with kernel text or data. */ -if (xen_is_e820_reserved (__pa_symbol (_text), -__pa_symbol (_end) -__pa_symbol (_text))) { -xen_raw_console_write ("Xen hypervisor allocated kernel memory conflicts with E820 map\n" ); -BUG (); - } +xen_chk_is_e820_usable (__pa_symbol (_text), +__pa_symbol (_end) -__pa_symbol (_text), +"kernel" ); + +/* +* Check for a conflict of the xen_start_info memory with the target +* E820 map. +*/ +xen_chk_is_e820_usable (__pa (xen_start_info),sizeof (*xen_start_info), +"xen_start_info" );/* * Check for a conflict of the hypervisor supplied page tables with
arch/x86/xen/xen-ops.h +2 -1
@@ -44,7 +44,8 @@ void xen_mm_unpin_all(void);void __init xen_relocate_p2m (void );#endif -bool __init xen_is_e820_reserved (phys_addr_t start,phys_addr_t size); +void __init xen_chk_is_e820_usable (phys_addr_t start,phys_addr_t size, +const char *component);unsigned long __ref xen_chk_extra_mem (unsigned long pfn);void __init xen_inv_extra_mem (void );void __init xen_remap_memory (void );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 221/634 xen: move max_pfn in xen_memory_setup() out of function scope
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit 43dc2a0f479b9cd30f6674986d7a40517e999d31 ]
Instead of having max_pfn as a local variable of xen_memory_setup(), make it a static variable in setup.c instead. This avoids having to pass it to subfunctions, which will be needed in more cases in future.
Rename it to ini_nr_pages, as the value denotes the currently usable number of memory pages as passed from the hypervisor at boot time.
Stable-dep-of: be35d91c8880 ("xen: tolerate ACPI NVS memory overlapping with Xen allocated memory")
--- arch/x86/xen/setup.c | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-)
arch/x86/xen/setup.c +26 -26
@@ -47,6 +47,9 @@ bool xen_pv_pci_possible;/* E820 map used during setting up memory. */ static struct e820_table xen_e820_table__initdata ; +/* Number of initially usable memory pages. */ +static unsigned long ini_nr_pages__initdata ; +/* * Buffer used to remap identity mapped pages. We only need the virtual space. * The physical page behind this address is remapped as needed to different
@@ -213,7 +216,7 @@ static int __init xen_free_mfn(unsigned long mfn)* as a fallback if the remapping fails. */ static void __init xen_set_identity_and_release_chunk (unsigned long start_pfn, -unsigned long end_pfn,unsigned long nr_pages) +unsigned long end_pfn) {unsigned long pfn, end;int ret;
@@ -221,7 +224,7 @@ static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn,WARN_ON (start_pfn > end_pfn);/* Release pages first. */ - end =min (end_pfn, nr_pages); + end =min (end_pfn, ini_nr_pages);for (pfn = start_pfn; pfn < end; pfn++) {unsigned long mfn =pfn_to_mfn (pfn);
@@ -342,15 +345,14 @@ static void __init xen_do_set_identity_and_remap_chunk(* to Xen and not remapped. */ static unsigned long __init xen_set_identity_and_remap_chunk ( -unsigned long start_pfn,unsigned long end_pfn,unsigned long nr_pages, -unsigned long remap_pfn) +unsigned long start_pfn,unsigned long end_pfn,unsigned long remap_pfn) {unsigned long pfn;unsigned long i =0 ;unsigned long n = end_pfn - start_pfn;if (remap_pfn ==0 ) - remap_pfn = nr_pages; + remap_pfn = ini_nr_pages;while (i < n) {unsigned long cur_pfn = start_pfn + i;
@@ -359,19 +361,19 @@ static unsigned long __init xen_set_identity_and_remap_chunk(unsigned long remap_range_size;/* Do not remap pages beyond the current allocation */ -if (cur_pfn >= nr_pages) { +if (cur_pfn >= ini_nr_pages) {/* Identity map remaining pages */ set_phys_range_identity (cur_pfn, cur_pfn + size);break ; } -if (cur_pfn + size > nr_pages) - size = nr_pages - cur_pfn; +if (cur_pfn + size > ini_nr_pages) + size = ini_nr_pages - cur_pfn; remap_range_size =xen_find_pfn_range (&remap_pfn);if (!remap_range_size) {pr_warn ("Unable to find available pfn range, not remapping identity pages\n" );xen_set_identity_and_release_chunk (cur_pfn, - cur_pfn + left, nr_pages); + cur_pfn + left);break ; }/* Adjust size to fit in current e820 RAM region */
@@ -398,18 +400,18 @@ static unsigned long __init xen_set_identity_and_remap_chunk( }static unsigned long __init xen_count_remap_pages ( -unsigned long start_pfn,unsigned long end_pfn,unsigned long nr_pages, +unsigned long start_pfn,unsigned long end_pfn,unsigned long remap_pages) { -if (start_pfn >= nr_pages) +if (start_pfn >= ini_nr_pages)return remap_pages; -return remap_pages +min (end_pfn, nr_pages) - start_pfn; +return remap_pages +min (end_pfn, ini_nr_pages) - start_pfn; } -static unsigned long __init xen_foreach_remap_area (unsigned long nr_pages, +static unsigned long __init xen_foreach_remap_area (unsigned long (*func)(unsigned long start_pfn,unsigned long end_pfn, -unsigned long nr_pages,unsigned long last_val)) +unsigned long last_val)) {phys_addr_t start =0 ;unsigned long ret_val =0 ;
@@ -437,8 +439,7 @@ static unsigned long __init xen_foreach_remap_area(unsigned long nr_pages, end_pfn =PFN_UP (entry->addr);if (start_pfn < end_pfn) - ret_val =func (start_pfn, end_pfn, nr_pages, - ret_val); + ret_val =func (start_pfn, end_pfn, ret_val); start = end; } }
@@ -701,7 +702,7 @@ static void __init xen_reserve_xen_mfnlist(void)**/ char *__init xen_memory_setup (void ) { -unsigned long max_pfn, pfn_s, n_pfns; +unsigned long pfn_s, n_pfns;phys_addr_t mem_end, addr, size, chunk_size;u32 type;int rc;
@@ -713,9 +714,8 @@ char * __init xen_memory_setup(void)int op;xen_parse_512gb (); - max_pfn =xen_get_pages_limit (); - max_pfn =min (max_pfn, xen_start_info->nr_pages); - mem_end =PFN_PHYS (max_pfn); + ini_nr_pages =min (xen_get_pages_limit (), xen_start_info->nr_pages); + mem_end =PFN_PHYS (ini_nr_pages); memmap.nr_entries =ARRAY_SIZE (xen_e820_table.entries);set_xen_guest_handle (memmap.buffer, xen_e820_table.entries);
@@ -768,10 +768,10 @@ char * __init xen_memory_setup(void) max_pages =xen_get_max_pages ();/* How many extra pages do we need due to remapping? */ - max_pages +=xen_foreach_remap_area (max_pfn, xen_count_remap_pages); + max_pages +=xen_foreach_remap_area (xen_count_remap_pages); -if (max_pages > max_pfn) - extra_pages += max_pages - max_pfn; +if (max_pages > ini_nr_pages) + extra_pages += max_pages - ini_nr_pages;/* * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
@@ -780,8 +780,8 @@ char * __init xen_memory_setup(void)* Make sure we have no memory above max_pages, as this area * isn't handled by the p2m management. */ - maxmem_pages =EXTRA_MEM_RATIO *min (max_pfn,PFN_DOWN (MAXMEM )); - extra_pages =min3 (maxmem_pages, extra_pages, max_pages - max_pfn); + maxmem_pages =EXTRA_MEM_RATIO *min (ini_nr_pages,PFN_DOWN (MAXMEM )); + extra_pages =min3 (maxmem_pages, extra_pages, max_pages - ini_nr_pages); i =0 ; addr = xen_e820_table.entries[0 ].addr; size = xen_e820_table.entries[0 ].size;
@@ -886,7 +886,7 @@ char * __init xen_memory_setup(void)* Set identity map on non-RAM pages and prepare remapping the * underlying RAM. */ -xen_foreach_remap_area (max_pfn, xen_set_identity_and_remap_chunk); +xen_foreach_remap_area (xen_set_identity_and_remap_chunk);pr_info ("Released %ld page(s)\n" , xen_released_pages);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 222/634 xen: add capability to remap non-RAM pages to different PFNs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit d05208cf7f05420ad10cc7f9550f91d485523659 ]
When running as a Xen PV dom0 it can happen that the kernel is being loaded to a guest physical address conflicting with the host memory map.
In order to be able to resolve this conflict, add the capability to remap non-RAM areas to different guest PFNs. A function to use this remapping information for other purposes than doing the remap will be added when needed.
As the number of conflicts should be rather low (currently only machines with max. 1 conflict are known), save the remap data in a small statically allocated array.
Stable-dep-of: be35d91c8880 ("xen: tolerate ACPI NVS memory overlapping with Xen allocated memory")
--- arch/x86/xen/p2m.c | 63 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/xen/xen-ops.h | 3 ++ 2 files changed, 66 insertions(+)
arch/x86/xen/p2m.c +63 -0
@@ -80,6 +80,7 @@#include <asm/xen/hypervisor.h> #include <xen/balloon.h> #include <xen/grant_table.h> +#include <xen/hvc-console.h> #include "multicalls.h" #include "xen-ops.h"
@@ -793,6 +794,68 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,return ret; } +/* Remapped non-RAM areas */ +#define NR_NONRAM_REMAP 4 +static struct nonram_remap { +phys_addr_t maddr; +phys_addr_t paddr; +size_t size; +} xen_nonram_remap[NR_NONRAM_REMAP ]__ro_after_init ; +static unsigned int nr_nonram_remap__ro_after_init ; + +/* +* Do the real remapping of non-RAM regions as specified in the +* xen_nonram_remap[] array. +* In case of an error just crash the system. +*/ +void __init xen_do_remap_nonram (void ) +{ +unsigned int i; +unsigned int remapped =0 ; +const struct nonram_remap *remap = xen_nonram_remap; +unsigned long pfn, mfn, end_pfn; + +for (i =0 ; i < nr_nonram_remap; i++) { + end_pfn =PFN_UP (remap->paddr + remap->size); + pfn =PFN_DOWN (remap->paddr); + mfn =PFN_DOWN (remap->maddr); +while (pfn < end_pfn) { +if (!set_phys_to_machine (pfn, mfn)) +panic ("Failed to set p2m mapping for pfn=%lx mfn=%lx\n" , + pfn, mfn); + + pfn++; + mfn++; + remapped++; + } + + remap++; + } + +pr_info ("Remapped %u non-RAM page(s)\n" , remapped); +} + +/* +* Add a new non-RAM remap entry. +* In case of no free entry found, just crash the system. +*/ +void __init xen_add_remap_nonram (phys_addr_t maddr,phys_addr_t paddr, +unsigned long size) +{ +BUG_ON ((maddr & ~PAGE_MASK ) != (paddr & ~PAGE_MASK )); + +if (nr_nonram_remap ==NR_NONRAM_REMAP ) { +xen_raw_console_write ("Number of required E820 entry remapping actions exceed maximum value\n" ); +BUG (); + } + + xen_nonram_remap[nr_nonram_remap].maddr = maddr; + xen_nonram_remap[nr_nonram_remap].paddr = paddr; + xen_nonram_remap[nr_nonram_remap].size = size; + + nr_nonram_remap++; +} +#ifdef CONFIG_XEN_DEBUG_FS #include <linux/debugfs.h> #include "debugfs.h"
arch/x86/xen/xen-ops.h +3 -0
@@ -43,6 +43,9 @@ void xen_mm_unpin_all(void);#ifdef CONFIG_X86_64 void __init xen_relocate_p2m (void );#endif +void __init xen_do_remap_nonram (void ); +void __init xen_add_remap_nonram (phys_addr_t maddr,phys_addr_t paddr, +unsigned long size);void __init xen_chk_is_e820_usable (phys_addr_t start,phys_addr_t size,const char *component);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 223/634 xen: tolerate ACPI NVS memory overlapping with Xen allocated memory
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit be35d91c8880650404f3bf813573222dfb106935 ]
In order to minimize required special handling for running as Xen PV dom0, the memory layout is modified to match that of the host. This requires to have only RAM at the locations where Xen allocated memory is living. Unfortunately there seem to be some machines, where ACPI NVS is located at 64 MB, resulting in a conflict with the loaded kernel or the initial page tables built by Xen.
Avoid this conflict by swapping the ACPI NVS area in the memory map with unused RAM. This is possible via modification of the dom0 P2M map. Accesses to the ACPI NVS area are done either for saving and restoring it across suspend operations (this will work the same way as before), or by ACPI code when NVS memory is referenced from other ACPI tables. The latter case is handled by a Xen specific indirection of acpi_os_ioremap().
While the E820 map can (and should) be modified right away, the P2M map can be updated only after memory allocation is working, as the P2M map might need to be extended.
--- arch/x86/xen/setup.c | 92 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)
arch/x86/xen/setup.c +91 -1
@@ -496,6 +496,8 @@ void __init xen_remap_memory(void)set_pte_mfn (buf, mfn_save,PAGE_KERNEL );pr_info ("Remapped %ld page(s)\n" , remapped); + +xen_do_remap_nonram (); }static unsigned long __init xen_get_pages_limit (void )
@@ -626,14 +628,102 @@ phys_addr_t __init xen_find_free_area(phys_addr_t size)return 0 ; } +/* +* Swap a non-RAM E820 map entry with RAM above ini_nr_pages. +* Note that the E820 map is modified accordingly, but the P2M map isn't yet. +* The adaption of the P2M must be deferred until page allocation is possible. +*/ +static void __init xen_e820_swap_entry_with_ram (struct e820_entry *swap_entry) +{ +struct e820_entry *entry; +unsigned int mapcnt; +phys_addr_t mem_end =PFN_PHYS (ini_nr_pages); +phys_addr_t swap_addr, swap_size, entry_end; + + swap_addr =PAGE_ALIGN_DOWN (swap_entry->addr); + swap_size =PAGE_ALIGN (swap_entry->addr - swap_addr + swap_entry->size); + entry = xen_e820_table.entries; + +for (mapcnt =0 ; mapcnt < xen_e820_table.nr_entries; mapcnt++) { + entry_end = entry->addr + entry->size; +if (entry->type ==E820_TYPE_RAM && entry->size >= swap_size && + entry_end - swap_size >= mem_end) { +/* Reduce RAM entry by needed space (whole pages). */ + entry->size -= swap_size; + +/* Add new entry at the end of E820 map. */ + entry = xen_e820_table.entries + + xen_e820_table.nr_entries; + xen_e820_table.nr_entries++; + +/* Fill new entry (keep size and page offset). */ + entry->type = swap_entry->type; + entry->addr = entry_end - swap_size + + swap_addr - swap_entry->addr; + entry->size = swap_entry->size; + +/* Convert old entry to RAM, align to pages. */ + swap_entry->type =E820_TYPE_RAM ; + swap_entry->addr = swap_addr; + swap_entry->size = swap_size; + +/* Remember PFN<->MFN relation for P2M update. */ +xen_add_remap_nonram (swap_addr, entry_end - swap_size, + swap_size); + +/* Order E820 table and merge entries. */ +e820__update_table (&xen_e820_table); + +return ; + } + + entry++; + } + +xen_raw_console_write ("No suitable area found for required E820 entry remapping action\n" ); +BUG (); +} + +/* +* Look for non-RAM memory types in a specific guest physical area and move +* those away if possible (ACPI NVS only for now). +*/ +static void __init xen_e820_resolve_conflicts (phys_addr_t start, +phys_addr_t size) +{ +struct e820_entry *entry; +unsigned int mapcnt; +phys_addr_t end; + +if (!size) +return ; + + end = start + size; + entry = xen_e820_table.entries; + +for (mapcnt =0 ; mapcnt < xen_e820_table.nr_entries; mapcnt++) { +if (entry->addr >= end) +return ; + +if (entry->addr + entry->size > start && + entry->type ==E820_TYPE_NVS ) +xen_e820_swap_entry_with_ram (entry); + + entry++; + } +} +/* * Check for an area in physical memory to be usable for non-movable purposes. -* An area is considered to usable if the used E820 map lists it to be RAM. +* An area is considered to usable if the used E820 map lists it to be RAM or +* some other type which can be moved to higher PFNs while keeping the MFNs. * In case the area is not usable, crash the system with an error message. */ void __init xen_chk_is_e820_usable (phys_addr_t start,phys_addr_t size,const char *component) { +xen_e820_resolve_conflicts (start, size); +if (!xen_is_e820_reserved (start, size))return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 224/634 xen/swiotlb: add alignment check for dma buffers
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit 9f40ec84a7976d95c34e7cc070939deb103652b0 ]
When checking a memory buffer to be consecutive in machine memory, the alignment needs to be checked, too. Failing to do so might result in DMA memory not being aligned according to its requested size, leading to error messages like:
4xxx 0000:2b:00.0: enabling device (0140 -> 0142) 4xxx 0000:2b:00.0: Ring address not aligned
4xxx 0000:2b:00.0: Failed to initialise service qat_crypto 4xxx 0000:2b:00.0: Resetting device qat_dev0 4xxx: probe of 0000:2b:00.0 failed with error -14
--- drivers/xen/swiotlb-xen.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/xen/swiotlb-xen.c +6 -0
@@ -78,9 +78,15 @@ static inline int range_straddles_page_boundary(phys_addr_t p, size_t size) {unsigned long next_bfn, xen_pfn =XEN_PFN_DOWN (p);unsigned int i, nr_pages =XEN_PFN_UP (xen_offset_in_page (p) + size); +phys_addr_t algn =1ULL << (get_order (size) +PAGE_SHIFT ); next_bfn =pfn_to_bfn (xen_pfn); +/* If buffer is physically aligned, ensure DMA alignment. */ +if (IS_ALIGNED (p, algn) && + !IS_ALIGNED ((phys_addr_t )next_bfn <<XEN_PAGE_SHIFT , algn)) +return 1 ; +for (i =1 ; i < nr_pages; i++)if (pfn_to_bfn (++xen_pfn) != ++next_bfn)return 1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 225/634 xen/swiotlb: fix allocated size
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit c3dea3d54f4d399f8044547f0f1abdccbdfb0fee ]
The allocated size in xen_swiotlb_alloc_coherent() and xen_swiotlb_free_coherent() is calculated wrong for the case of XEN_PAGE_SIZE not matching PAGE_SIZE. Fix that.
--- drivers/xen/swiotlb-xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/swiotlb-xen.c +2 -2
@@ -146,7 +146,7 @@ xen_swiotlb_alloc_coherent(struct device *dev, size_t size,void *ret;/* Align the allocation to the Xen page size */ - size =1UL << (order +XEN_PAGE_SHIFT ); + size =ALIGN (size,XEN_PAGE_SIZE ); ret = (void *)__get_free_pages (flags,get_order (size));if (!ret)
@@ -178,7 +178,7 @@ xen_swiotlb_free_coherent(struct device *dev, size_t size, void *vaddr,int order =get_order (size);/* Convert the size to actually allocated. */ - size =1UL << (order +XEN_PAGE_SHIFT ); + size =ALIGN (size,XEN_PAGE_SIZE );if (WARN_ON_ONCE (dma_handle + size -1 > dev->coherent_dma_mask) ||WARN_ON_ONCE (range_straddles_page_boundary (phys, size)))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 226/634 tpm: Clean up TPM space after command failure
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan McDowell <[email protected]>
[ Upstream commit e3aaebcbb7c6b403416f442d1de70d437ce313a7 ]
tpm_dev_transmit prepares the TPM space before attempting command transmission. However if the command fails no rollback of this preparation is done. This can result in transient handles being leaked if the device is subsequently closed with no further commands performed.
Fix this by flushing the space in the event of command transmission failure.
--- drivers/char/tpm/tpm-dev-common.c | 2 ++ drivers/char/tpm/tpm2-space.c | 3 +++ 2 files changed, 5 insertions(+)
drivers/char/tpm/tpm-dev-common.c +2 -0
@@ -47,6 +47,8 @@ static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space,if (!ret) ret =tpm2_commit_space (chip, space, buf, &len); +else +tpm2_flush_space (chip); out_rc:return ret ? ret : len;
drivers/char/tpm/tpm2-space.c +3 -0
@@ -169,6 +169,9 @@ void tpm2_flush_space(struct tpm_chip *chip)struct tpm_space *space = &chip->work_space;int i; +if (!space) +return ; +for (i =0 ; i <ARRAY_SIZE (space->context_tbl); i++)if (space->context_tbl[i] && ~space->context_tbl[i])tpm2_flush_context (chip, space->context_tbl[i]);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 227/634 sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchen Ding <[email protected]>
[ Upstream commit faa42d29419def58d3c3e5b14ad4037f0af3b496 ]
Consider the following cgroup:
root
|
------------------------
| |
normal_cgroup idle_cgroup
| | SCHED_IDLE task_A SCHED_NORMAL task_B
According to the cgroup hierarchy, A should preempt B. But current check_preempt_wakeup_fair() treats cgroup se and task separately, so B will preempt A unexpectedly.
Unify the wakeup logic by {c,p}se_is_idle only. This makes SCHED_IDLE of a task a relative policy that is effective only within its own cgroup, similar to the behavior of NICE.
Also fix se_is_idle() definition when !CONFIG_FAIR_GROUP_SCHED.
--- kernel/sched/fair.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
kernel/sched/fair.c +9 -13
@@ -511,7 +511,7 @@ static int cfs_rq_is_idle(struct cfs_rq *cfs_rq)static int se_is_idle (struct sched_entity *se) { -return 0 ; +return task_has_idle_policy (task_of (se)); }#endif /* CONFIG_FAIR_GROUP_SCHED */
@@ -8381,16 +8381,7 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intif (test_tsk_need_resched (curr))return ; -/* Idle tasks are by definition preempted by non-idle tasks. */ -if (unlikely (task_has_idle_policy (curr)) && -likely (!task_has_idle_policy (p))) - goto preempt; - -/* -* Batch and idle tasks do not preempt non-idle tasks (their preemption -* is driven by the tick): -*/ -if (unlikely (p->policy !=SCHED_NORMAL ) || !sched_feat (WAKEUP_PREEMPTION )) +if (!sched_feat (WAKEUP_PREEMPTION ))return ;find_matching_se (&se, &pse);
@@ -8400,7 +8391,7 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int pse_is_idle =se_is_idle (pse);/* -* Preempt an idle group in favor of a non-idle group (and don't preempt +* Preempt an idle entity in favor of a non-idle entity (and don't preempt * in the inverse case). */ if (cse_is_idle && !pse_is_idle)
@@ -8408,9 +8399,14 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intif (cse_is_idle != pse_is_idle)return ; +/* +* BATCH and IDLE tasks do not preempt others. +*/ +if (unlikely (p->policy !=SCHED_NORMAL )) +return ; + cfs_rq =cfs_rq_of (se);update_curr (cfs_rq); -/* * XXX pick_eevdf(cfs_rq) != se ? */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 228/634 bpf, x64: Fix tailcall hierarchy
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 116e04ba1459fc08f80cf27b8c9f9f188be0fcb2 ]
This patch fixes a tailcall issue caused by abusing the tailcall in bpf2bpf feature.
As we know, tail_call_cnt propagates by rax from caller to callee when to call subprog in tailcall context. But, like the following example, MAX_TAIL_CALL_CNT won't work because of missing tail_call_cnt back-propagation from callee to caller.
\#include <linux/bpf.h>
\#include <bpf/bpf_helpers.h>
\#include "bpf_legacy.h"
struct {
__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
__uint(max_entries, 1);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(__u32));
} jmp_table SEC(".maps");int count = 0;
static __noinline
int subprog_tail1(struct __sk_buff *skb)
{
bpf_tail_call_static(skb, &jmp_table, 0);
return 0;
}static __noinline
int subprog_tail2(struct __sk_buff *skb)
{
bpf_tail_call_static(skb, &jmp_table, 0);
return 0;
}SEC("tc")
int entry(struct __sk_buff *skb)
{
volatile int ret = 1;
count++;
subprog_tail1(skb);
subprog_tail2(skb);
return ret;
}char __license[] SEC("license") = "GPL";
At run time, the tail_call_cnt in entry() will be propagated to subprog_tail1() and subprog_tail2(). But, when the tail_call_cnt in subprog_tail1() updates when bpf_tail_call_static(), the tail_call_cnt in entry() won't be updated at the same time. As a result, in entry(), when tail_call_cnt in entry() is less than MAX_TAIL_CALL_CNT and subprog_tail1() returns because of MAX_TAIL_CALL_CNT limit, bpf_tail_call_static() in suprog_tail2() is able to run because the tail_call_cnt in subprog_tail2() propagated from entry() is less than MAX_TAIL_CALL_CNT.
So, how many tailcalls are there for this case if no error happens?
Quoted 1 line
From top-down view, does it look like hierarchy layer and layer?
With this view, there will be 2+4+8+...+2^33 = 2^34 - 2 = 17,179,869,182 tailcalls for this case.
How about there are N subprog_tail() in entry()? There will be almost N^34 tailcalls.
Then, in this patch, it resolves this case on x86_64.
In stead of propagating tail_call_cnt from caller to callee, it propagates its pointer, tail_call_cnt_ptr, tcc_ptr for short.
However, where does it store tail_call_cnt?
It stores tail_call_cnt on the stack of main prog. When tail call happens in subprog, it increments tail_call_cnt by tcc_ptr.
Meanwhile, it stores tail_call_cnt_ptr on the stack of main prog, too.
And, before jump to tail callee, it has to pop tail_call_cnt and tail_call_cnt_ptr.
Then, at the prologue of subprog, it must not make rax as tail_call_cnt_ptr again. It has to reuse tail_call_cnt_ptr from caller.
As a result, at run time, it has to recognize rax is tail_call_cnt or tail_call_cnt_ptr at prologue by:
1. rax is tail_call_cnt if rax is <= MAX_TAIL_CALL_CNT.
2. rax is tail_call_cnt_ptr if rax is > MAX_TAIL_CALL_CNT, because a pointer won't be <= MAX_TAIL_CALL_CNT.
Here's an example to dump JITed.
struct {
__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
__uint(max_entries, 1);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(__u32));
} jmp_table SEC(".maps");int count = 0;
static __noinline
int subprog_tail(struct __sk_buff *skb)
{
bpf_tail_call_static(skb, &jmp_table, 0);
return 0;
}SEC("tc")
int entry(struct __sk_buff *skb)
{
int ret = 1;
count++;
subprog_tail(skb);
subprog_tail(skb);
return ret;
}When bpftool p d j id 42:
int entry(struct __sk_buff * skb):bpf_prog_0c0f4c2413ef19b1_entry:
; int entry(struct __sk_buff *skb)
0: endbr64
4: nopl (%rax,%rax)
9: xorq %rax, %rax ;; rax = 0 (tail_call_cnt)
c: pushq %rbp
d: movq %rsp, %rbp
10: endbr64
14: cmpq $33, %rax ;; if rax > 33, rax = tcc_ptr
18: ja 0x20 ;; if rax > 33 goto 0x20 ---+
1a: pushq %rax ;; [rbp - 8] = rax = 0 |
1b: movq %rsp, %rax ;; rax = rbp - 8 |
1e: jmp 0x21 ;; ---------+ |
20: pushq %rax ;; <--------|---------------+
21: pushq %rax ;; <--------+ [rbp - 16] = rax
22: pushq %rbx ;; callee saved
23: movq %rdi, %rbx ;; rbx = skb (callee saved)
; count++;
26: movabsq $-82417199407104, %rdi
30: movl (%rdi), %esi
33: addl $1, %esi
36: movl %esi, (%rdi)
; subprog_tail(skb);
39: movq %rbx, %rdi ;; rdi = skb
3c: movq -16(%rbp), %rax ;; rax = tcc_ptr
43: callq 0x80 ;; call subprog_tail()
; subprog_tail(skb);
48: movq %rbx, %rdi ;; rdi = skb
4b: movq -16(%rbp), %rax ;; rax = tcc_ptr
52: callq 0x80 ;; call subprog_tail()
; return ret;
57: movl $1, %eax
5c: popq %rbx
5d: leave
5e: retq
int subprog_tail(struct __sk_buff * skb):bpf_prog_3a140cef239a4b4f_subprog_tail:
; int subprog_tail(struct __sk_buff *skb)
0: endbr64
4: nopl (%rax,%rax)
9: nopl (%rax) ;; do not touch tail_call_cnt
c: pushq %rbp
d: movq %rsp, %rbp
10: endbr64
14: pushq %rax ;; [rbp - 8] = rax (tcc_ptr)
15: pushq %rax ;; [rbp - 16] = rax (tcc_ptr)
16: pushq %rbx ;; callee saved
17: pushq %r13 ;; callee saved
19: movq %rdi, %rbx ;; rbx = skb
; asm volatile("r1 = %[ctx]\n\t"
1c: movabsq $-105487587488768, %r13 ;; r13 = jmp_table
26: movq %rbx, %rdi ;; 1st arg, skb
29: movq %r13, %rsi ;; 2nd arg, jmp_table
2c: xorl %edx, %edx ;; 3rd arg, index = 0
2e: movq -16(%rbp), %rax ;; rax = [rbp - 16] (tcc_ptr)
35: cmpq $33, (%rax)
39: jae 0x4e ;; if *tcc_ptr >= 33 goto 0x4e --------+
3b: jmp 0x4e ;; jmp bypass, toggled by poking |
40: addq $1, (%rax) ;; (*tcc_ptr)++ |
44: popq %r13 ;; callee saved | 46: popq %rbx ;; callee saved | 47: popq %rax ;; undo rbp-16 push | 48: popq %rax ;; undo rbp-8 push |
49: nopl (%rax,%rax) ;; tail call target, toggled by poking |
; return 0; ;; |
4e: popq %r13 ;; restore callee saved <--------------+
50: popq %rbx ;; restore callee saved
51: leave
52: retq
Furthermore, when trampoline is the caller of bpf prog, which is tail_call_reachable, it is required to propagate rax through trampoline.
--- arch/x86/net/bpf_jit_comp.c | 107 ++++++++++++++++++++++++++---------- 1 file changed, 79 insertions(+), 28 deletions(-)
arch/x86/net/bpf_jit_comp.c +79 -28
@@ -273,7 +273,7 @@ struct jit_context {/* Number of bytes emit_patch() needs to generate instructions */ #define X86_PATCH_SIZE 5/* Number of bytes that will be skipped on tailcall */ -#define X86_TAIL_CALL_OFFSET (11 + ENDBR_INSN_SIZE) +#define X86_TAIL_CALL_OFFSET (12 + ENDBR_INSN_SIZE)static void push_r12 (u8 **pprog) {
@@ -403,6 +403,37 @@ static void emit_cfi(u8 **pprog, u32 hash) *pprog = prog; } +static void emit_prologue_tail_call (u8 **pprog,bool is_subprog) +{ +u8 *prog = *pprog; + +if (!is_subprog) { +/* cmp rax, MAX_TAIL_CALL_CNT */ +EMIT4 (0x48 ,0x83 ,0xF8 ,MAX_TAIL_CALL_CNT ); +EMIT2 (X86_JA ,6 );/* ja 6 */ +/* rax is tail_call_cnt if <= MAX_TAIL_CALL_CNT. +* case1: entry of main prog. +* case2: tail callee of main prog. +*/ +EMIT1 (0x50 );/* push rax */ +/* Make rax as tail_call_cnt_ptr. */ +EMIT3 (0x48 ,0x89 ,0xE0 );/* mov rax, rsp */ +EMIT2 (0xEB ,1 );/* jmp 1 */ +/* rax is tail_call_cnt_ptr if > MAX_TAIL_CALL_CNT. +* case: tail callee of subprog. +*/ +EMIT1 (0x50 );/* push rax */ +/* push tail_call_cnt_ptr */ +EMIT1 (0x50 );/* push rax */ + }else {/* is_subprog */ +/* rax is tail_call_cnt_ptr. */ +EMIT1 (0x50 );/* push rax */ +EMIT1 (0x50 );/* push rax */ + } + + *pprog = prog; +} +/* * Emit x86-64 prologue code for BPF program. * bpf_tail_call helper will skip the first X86_TAIL_CALL_OFFSET bytes
@@ -424,10 +455,10 @@ static void emit_prologue(u8 **pprog, u32 stack_depth, bool ebpf_from_cbpf,/* When it's the entry of the whole tailcall context, * zeroing rax means initialising tail_call_cnt. */ -EMIT2 (0x31 ,0xC0 );/* xor eax, eax */ +EMIT3 (0x48 ,0x31 ,0xC0 );/* xor rax, rax */ else/* Keep the same instruction layout. */ - EMIT2(0x66, 0x90); /* nop2 */ + emit_nops(&prog, 3); /* nop3 */ }/* Exception callback receives FP as third parameter */ if (is_exception_cb) {
@@ -453,7 +484,7 @@ static void emit_prologue(u8 **pprog, u32 stack_depth, bool ebpf_from_cbpf,if (stack_depth)EMIT3_off32 (0x48 ,0x81 ,0xEC ,round_up (stack_depth,8 ));if (tail_call_reachable) -EMIT1 (0x50 );/* push rax */ +emit_prologue_tail_call (&prog, is_subprog); *pprog = prog; }
@@ -589,13 +620,15 @@ static void emit_return(u8 **pprog, u8 *ip) *pprog = prog; } +#define BPF_TAIL_CALL_CNT_PTR_STACK_OFF (stack) (-16 - round_up(stack, 8)) +/* * Generate the following code: * * ... bpf_tail_call(void *ctx, struct bpf_array *array, u64 index) ... * if (index >= array->map.max_entries) * goto out; -* if (tail_call_cnt++ >= MAX_TAIL_CALL_CNT) +* if ((*tcc_ptr)++ >= MAX_TAIL_CALL_CNT) * goto out; * prog = array->ptrs[index]; * if (prog == NULL)
@@ -608,7 +641,7 @@ static void emit_bpf_tail_call_indirect(struct bpf_prog *bpf_prog, u32 stack_depth, u8 *ip, struct jit_context *ctx) { - int tcc_off = -4 - round_up(stack_depth, 8); + int tcc_ptr_off = BPF_TAIL_CALL_CNT_PTR_STACK_OFF(stack_depth);u8 *prog = *pprog, *start = *pprog;int offset;
@@ -630,16 +663,14 @@ static void emit_bpf_tail_call_indirect(struct bpf_prog *bpf_prog,EMIT2 (X86_JBE , offset);/* jbe out */ /* -* if (tail_call_cnt++ >= MAX_TAIL_CALL_CNT) +* if ((*tcc_ptr)++ >= MAX_TAIL_CALL_CNT) * goto out; */ -EMIT2_off32 (0x8B ,0x85 , tcc_off);/* mov eax, dword ptr [rbp - tcc_off] */ -EMIT3 (0x83 ,0xF8 ,MAX_TAIL_CALL_CNT );/* cmp eax, MAX_TAIL_CALL_CNT */ +EMIT3_off32 (0x48 ,0x8B ,0x85 , tcc_ptr_off);/* mov rax, qword ptr [rbp - tcc_ptr_off] */ +EMIT4 (0x48 ,0x83 ,0x38 ,MAX_TAIL_CALL_CNT );/* cmp qword ptr [rax], MAX_TAIL_CALL_CNT */ offset = ctx->tail_call_indirect_label - (prog +2 - start);EMIT2 (X86_JAE , offset);/* jae out */ -EMIT3 (0x83 ,0xC0 ,0x01 );/* add eax, 1 */ -EMIT2_off32 (0x89 ,0x85 , tcc_off);/* mov dword ptr [rbp - tcc_off], eax */ /* prog = array->ptrs[index]; */ EMIT4_off32(0x48, 0x8B, 0x8C, 0xD6, /* mov rcx, [rsi + rdx * 8 + offsetof(...)] */
@@ -654,6 +685,9 @@ static void emit_bpf_tail_call_indirect(struct bpf_prog *bpf_prog, offset = ctx->tail_call_indirect_label - (prog +2 - start);EMIT2 (X86_JE , offset);/* je out */ +/* Inc tail_call_cnt if the slot is populated. */ +EMIT4 (0x48 ,0x83 ,0x00 ,0x01 );/* add qword ptr [rax], 1 */ +if (bpf_prog->aux->exception_boundary) {pop_callee_regs (&prog, all_callee_regs_used);pop_r12 (&prog);
@@ -663,6 +697,11 @@ static void emit_bpf_tail_call_indirect(struct bpf_prog *bpf_prog,pop_r12 (&prog); } +/* Pop tail_call_cnt_ptr. */ +EMIT1 (0x58 );/* pop rax */ +/* Pop tail_call_cnt, if it's main prog. +* Pop tail_call_cnt_ptr, if it's subprog. +*/ EMIT1 (0x58 );/* pop rax */ if (stack_depth) EMIT3_off32(0x48, 0x81, 0xC4, /* add rsp, sd */
@@ -691,21 +730,19 @@ static void emit_bpf_tail_call_direct(struct bpf_prog *bpf_prog, bool *callee_regs_used, u32 stack_depth, struct jit_context *ctx) { - int tcc_off = -4 - round_up(stack_depth, 8); + int tcc_ptr_off = BPF_TAIL_CALL_CNT_PTR_STACK_OFF(stack_depth);u8 *prog = *pprog, *start = *pprog;int offset;/* -* if (tail_call_cnt++ >= MAX_TAIL_CALL_CNT) +* if ((*tcc_ptr)++ >= MAX_TAIL_CALL_CNT) * goto out; */ -EMIT2_off32 (0x8B ,0x85 , tcc_off);/* mov eax, dword ptr [rbp - tcc_off] */ -EMIT3 (0x83 ,0xF8 ,MAX_TAIL_CALL_CNT );/* cmp eax, MAX_TAIL_CALL_CNT */ +EMIT3_off32 (0x48 ,0x8B ,0x85 , tcc_ptr_off);/* mov rax, qword ptr [rbp - tcc_ptr_off] */ +EMIT4 (0x48 ,0x83 ,0x38 ,MAX_TAIL_CALL_CNT );/* cmp qword ptr [rax], MAX_TAIL_CALL_CNT */ offset = ctx->tail_call_direct_label - (prog +2 - start);EMIT2 (X86_JAE , offset);/* jae out */ -EMIT3 (0x83 ,0xC0 ,0x01 );/* add eax, 1 */ -EMIT2_off32 (0x89 ,0x85 , tcc_off);/* mov dword ptr [rbp - tcc_off], eax */ poke->tailcall_bypass = ip + (prog - start); poke->adj_off =X86_TAIL_CALL_OFFSET ;
@@ -715,6 +752,9 @@ static void emit_bpf_tail_call_direct(struct bpf_prog *bpf_prog,emit_jump (&prog, (u8 *)poke->tailcall_target +X86_PATCH_SIZE , poke->tailcall_bypass); +/* Inc tail_call_cnt if the slot is populated. */ +EMIT4 (0x48 ,0x83 ,0x00 ,0x01 );/* add qword ptr [rax], 1 */ +if (bpf_prog->aux->exception_boundary) {pop_callee_regs (&prog, all_callee_regs_used);pop_r12 (&prog);
@@ -724,6 +764,11 @@ static void emit_bpf_tail_call_direct(struct bpf_prog *bpf_prog,pop_r12 (&prog); } +/* Pop tail_call_cnt_ptr. */ +EMIT1 (0x58 );/* pop rax */ +/* Pop tail_call_cnt, if it's main prog. +* Pop tail_call_cnt_ptr, if it's subprog. +*/ EMIT1 (0x58 );/* pop rax */ if (stack_depth)EMIT3_off32 (0x48 ,0x81 ,0xC4 ,round_up (stack_depth,8 ));
@@ -1313,9 +1358,11 @@ static void emit_shiftx(u8 **pprog, u32 dst_reg, u8 src_reg, bool is64, u8 op)#define INSN_SZ_DIFF (((addrs[i] - addrs[i - 1]) - (prog - temp))) -/* mov rax, qword ptr [rbp - rounded_stack_depth - 8] */ -#define RESTORE_TAIL_CALL_CNT (stack) \ - EMIT3_off32(0x48, 0x8B, 0x85, -round_up(stack, 8) - 8) +#define __LOAD_TCC_PTR (off) \ + EMIT3_off32(0x48, 0x8B, 0x85, off) +/* mov rax, qword ptr [rbp - rounded_stack_depth - 16] */ +#define LOAD_TAIL_CALL_CNT_PTR (stack) \ + __LOAD_TCC_PTR(BPF_TAIL_CALL_CNT_PTR_STACK_OFF(stack))static int do_jit (struct bpf_prog *bpf_prog,int *addrs,u8 *image,u8 *rw_image,int oldproglen,struct jit_context *ctx,bool jmp_padding)
@@ -2038,7 +2085,7 @@ st: if (is_imm8(insn->off)) func = (u8 *) __bpf_call_base + imm32;if (tail_call_reachable) { -RESTORE_TAIL_CALL_CNT (bpf_prog->aux->stack_depth); +LOAD_TAIL_CALL_CNT_PTR (bpf_prog->aux->stack_depth); ip +=7 ; }if (!imm32)
@@ -2713,6 +2760,10 @@ static int invoke_bpf_mod_ret(const struct btf_func_model *m, u8 **pprog,return 0 ; } +/* mov rax, qword ptr [rbp - rounded_stack_depth - 8] */ +#define LOAD_TRAMP_TAIL_CALL_CNT_PTR (stack) \ + __LOAD_TCC_PTR(-round_up(stack, 8) - 8) +/* Example: * __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev); * its 'struct btf_func_model' will be nr_args=2
@@ -2833,7 +2884,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im* [ ... ] * [ stack_arg2 ] * RBP - arg_stack_off [ stack_arg1 ] -* RSP [ tail_call_cnt ] BPF_TRAMP_F_TAIL_CALL_CTX +* RSP [ tail_call_cnt_ptr ] BPF_TRAMP_F_TAIL_CALL_CTX */ /* room for return value of orig_call or fentry prog */
@@ -2962,10 +3013,10 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_imsave_args (m, &prog, arg_stack_off, true);if (flags &BPF_TRAMP_F_TAIL_CALL_CTX ) { -/* Before calling the original function, restore the -* tail_call_cnt from stack to rax. +/* Before calling the original function, load the +* tail_call_cnt_ptr from stack to rax. */ -RESTORE_TAIL_CALL_CNT (stack_size); +LOAD_TRAMP_TAIL_CALL_CNT_PTR (stack_size); }if (flags &BPF_TRAMP_F_ORIG_STACK ) {
@@ -3024,10 +3075,10 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im goto cleanup; } }else if (flags &BPF_TRAMP_F_TAIL_CALL_CTX ) { -/* Before running the original function, restore the -* tail_call_cnt from stack to rax. +/* Before running the original function, load the +* tail_call_cnt_ptr from stack to rax. */ -RESTORE_TAIL_CALL_CNT (stack_size); +LOAD_TRAMP_TAIL_CALL_CNT_PTR (stack_size); }/* restore return value of orig_call or fentry prog back into RAX */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 229/634 bpf, arm64: Fix tailcall hierarchy
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 66ff4d61dc124eafe9efaeaef696a09b7f236da2 ]
This patch fixes a tailcall issue caused by abusing the tailcall in bpf2bpf feature on arm64 like the way of "bpf, x64: Fix tailcall hierarchy".
On arm64, when a tail call happens, it uses tail_call_cnt_ptr to increment tail_call_cnt, too.
At the prologue of main prog, it has to initialize tail_call_cnt and prepare tail_call_cnt_ptr.
At the prologue of subprog, it pushes x26 register twice, and does not initialize tail_call_cnt.
At the epilogue, it pops x26 twice, no matter whether it is main prog or subprog.
--- arch/arm64/net/bpf_jit_comp.c | 57 +++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 16 deletions(-)
arch/arm64/net/bpf_jit_comp.c +41 -16
@@ -26,7 +26,7 @@#define TMP_REG_1 (MAX_BPF_JIT_REG + 0)#define TMP_REG_2 (MAX_BPF_JIT_REG + 1) -#define TCALL_CNT (MAX_BPF_JIT_REG + 2) +#define TCCNT_PTR (MAX_BPF_JIT_REG + 2)#define TMP_REG_3 (MAX_BPF_JIT_REG + 3)#define FP_BOTTOM (MAX_BPF_JIT_REG + 4)#define ARENA_VM_START (MAX_BPF_JIT_REG + 5)
@@ -63,8 +63,8 @@ static const int bpf2a64[] = { [TMP_REG_1] = A64_R(10), [TMP_REG_2] = A64_R(11), [TMP_REG_3] = A64_R(12), -/* tail_call_cnt */ - [TCALL_CNT] = A64_R(26), +/* tail_call_cnt_ptr */ + [TCCNT_PTR] = A64_R(26),/* temporary register for blinding constants */ [BPF_REG_AX] = A64_R(9), [FP_BOTTOM] = A64_R(27),
@@ -282,13 +282,35 @@ static bool is_lsi_offset(int offset, int scale)* mov x29, sp * stp x19, x20, [sp, #-16]! * stp x21, x22, [sp, #-16]! -* stp x25, x26, [sp, #-16]! +* stp x26, x25, [sp, #-16]! +* stp x26, x25, [sp, #-16]! * stp x27, x28, [sp, #-16]! * mov x25, sp * mov tcc, #0 * // PROLOGUE_OFFSET */ +static void prepare_bpf_tail_call_cnt (struct jit_ctx *ctx) +{ +const struct bpf_prog *prog = ctx->prog; +const bool is_main_prog = !bpf_is_subprog (prog); +const u8 ptr = bpf2a64[TCCNT_PTR ]; +const u8 fp = bpf2a64[BPF_REG_FP ]; +const u8 tcc = ptr; + +emit (A64_PUSH (ptr, fp,A64_SP ), ctx); +if (is_main_prog) { +/* Initialize tail_call_cnt. */ +emit (A64_MOVZ (1 , tcc,0 ,0 ), ctx); +emit (A64_PUSH (tcc, fp,A64_SP ), ctx); +emit (A64_MOV (1 , ptr,A64_SP ), ctx); + }else { +emit (A64_PUSH (ptr, fp,A64_SP ), ctx); +emit (A64_NOP , ctx); +emit (A64_NOP , ctx); + } +} +#define BTI_INSNS (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL) ? 1 : 0)#define PAC_INSNS (IS_ENABLED(CONFIG_ARM64_PTR_AUTH_KERNEL) ? 1 : 0)
@@ -296,7 +318,7 @@ static bool is_lsi_offset(int offset, int scale)#define POKE_OFFSET (BTI_INSNS + 1)/* Tail call offset to jump into */ -#define PROLOGUE_OFFSET (BTI_INSNS + 2 + PAC_INSNS + 8) +#define PROLOGUE_OFFSET (BTI_INSNS + 2 + PAC_INSNS + 10)static int build_prologue (struct jit_ctx *ctx,bool ebpf_from_cbpf,bool is_exception_cb,u64 arena_vm_start)
@@ -308,7 +330,6 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf,const u8 r8 = bpf2a64[BPF_REG_8 ];const u8 r9 = bpf2a64[BPF_REG_9 ];const u8 fp = bpf2a64[BPF_REG_FP ]; -const u8 tcc = bpf2a64[TCALL_CNT ];const u8 fpb = bpf2a64[FP_BOTTOM ];const u8 arena_vm_base = bpf2a64[ARENA_VM_START ];const int idx0 = ctx->idx;
@@ -359,7 +380,7 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf,/* Save callee-saved registers */ emit (A64_PUSH (r6, r7,A64_SP ), ctx);emit (A64_PUSH (r8, r9,A64_SP ), ctx); -emit (A64_PUSH (fp, tcc,A64_SP ), ctx); +prepare_bpf_tail_call_cnt (ctx);emit (A64_PUSH (fpb,A64_R (28 ),A64_SP ), ctx); }else {/*
@@ -372,18 +393,15 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf,* callee-saved registers. The exception callback will not push * anything and re-use the main program's stack. * -* 10 registers are on the stack +* 12 registers are on the stack */ -emit (A64_SUB_I (1 ,A64_SP ,A64_FP ,80 ), ctx); +emit (A64_SUB_I (1 ,A64_SP ,A64_FP ,96 ), ctx); }/* Set up BPF prog stack base register */ emit (A64_MOV (1 , fp,A64_SP ), ctx);if (!ebpf_from_cbpf && is_main_prog) { -/* Initialize tail_call_cnt */ -emit (A64_MOVZ (1 , tcc,0 ,0 ), ctx); - cur_offset = ctx->idx - idx0;if (cur_offset !=PROLOGUE_OFFSET ) { pr_err_once("PROLOGUE_OFFSET = %d, expected %d!\n",
@@ -432,7 +450,8 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx)const u8 tmp = bpf2a64[TMP_REG_1 ];const u8 prg = bpf2a64[TMP_REG_2 ]; -const u8 tcc = bpf2a64[TCALL_CNT ]; +const u8 tcc = bpf2a64[TMP_REG_3 ]; +const u8 ptr = bpf2a64[TCCNT_PTR ];const int idx0 = ctx->idx;#define cur_offset (ctx->idx - idx0)#define jmp_offset (out_offset - (cur_offset))
@@ -449,11 +468,12 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx)emit (A64_B_ (A64_COND_CS , jmp_offset), ctx);/* -* if (tail_call_cnt >= MAX_TAIL_CALL_CNT) +* if ((*tail_call_cnt_ptr) >= MAX_TAIL_CALL_CNT) * goto out; -* tail_call_cnt++; +* (*tail_call_cnt_ptr)++; */ emit_a64_mov_i64 (tmp,MAX_TAIL_CALL_CNT , ctx); +emit (A64_LDR64I (tcc, ptr,0 ), ctx);emit (A64_CMP (1 , tcc, tmp), ctx);emit (A64_B_ (A64_COND_CS , jmp_offset), ctx);emit (A64_ADD_I (1 , tcc, tcc,1 ), ctx);
@@ -469,6 +489,9 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx)emit (A64_LDR64 (prg, tmp, prg), ctx);emit (A64_CBZ (1 , prg, jmp_offset), ctx); +/* Update tail_call_cnt if the slot is populated. */ +emit (A64_STR64I (tcc, ptr,0 ), ctx); +/* goto *(prog->bpf_func + prologue_offset); */ off = offsetof(struct bpf_prog , bpf_func);emit_a64_mov_i64 (tmp, off, ctx);
@@ -721,6 +744,7 @@ static void build_epilogue(struct jit_ctx *ctx, bool is_exception_cb)const u8 r8 = bpf2a64[BPF_REG_8 ];const u8 r9 = bpf2a64[BPF_REG_9 ];const u8 fp = bpf2a64[BPF_REG_FP ]; +const u8 ptr = bpf2a64[TCCNT_PTR ];const u8 fpb = bpf2a64[FP_BOTTOM ];/* We're done with BPF stack */
@@ -738,7 +762,8 @@ static void build_epilogue(struct jit_ctx *ctx, bool is_exception_cb)/* Restore x27 and x28 */ emit (A64_POP (fpb,A64_R (28 ),A64_SP ), ctx);/* Restore fs (x25) and x26 */ -emit (A64_POP (fp,A64_R (26 ),A64_SP ), ctx); +emit (A64_POP (ptr, fp,A64_SP ), ctx); +emit (A64_POP (ptr, fp,A64_SP ), ctx);/* Restore callee-saved register */ emit (A64_POP (r8, r9,A64_SP ), ctx);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 230/634 bpf, lsm: Add check for BPF LSM return value
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Kuohai <[email protected]>
[ Upstream commit 5d99e198be279045e6ecefe220f5c52f8ce9bfd5 ]
A bpf prog returning a positive number attached to file_alloc_security hook makes kernel panic.
This happens because file system can not filter out the positive number returned by the LSM prog using IS_ERR, and misinterprets this positive number as a file pointer.
Given that hook file_alloc_security never returned positive number before the introduction of BPF LSM, and other BPF LSM hooks may encounter similar issues, this patch adds LSM return value check in verifier, to ensure no unexpected value is returned.
--- include/linux/bpf.h | 1 + include/linux/bpf_lsm.h | 8 ++++++ kernel/bpf/bpf_lsm.c | 34 ++++++++++++++++++++++- kernel/bpf/btf.c | 5 +++- kernel/bpf/verifier.c | 60 ++++++++++++++++++++++++++++++++++------- 5 files changed, 97 insertions(+), 11 deletions(-)
include/linux/bpf.h +1 -0
@@ -927,6 +927,7 @@ struct bpf_insn_access_aux { }; };struct bpf_verifier_log *log;/* for verbose logs */ +bool is_retval;/* is accessing function return value ? */ }; static inline void
include/linux/bpf_lsm.h +8 -0
@@ -9,6 +9,7 @@#include <linux/sched.h> #include <linux/bpf.h> +#include <linux/bpf_verifier.h> #include <linux/lsm_hooks.h> #ifdef CONFIG_BPF_LSM
@@ -45,6 +46,8 @@ void bpf_inode_storage_free(struct inode *inode);void bpf_lsm_find_cgroup_shim (const struct bpf_prog *prog,bpf_func_t *bpf_func); +int bpf_lsm_get_retval_range (const struct bpf_prog *prog, +struct bpf_retval_range *range);#else /* !CONFIG_BPF_LSM */ static inline bool bpf_lsm_is_sleepable_hook (u32 btf_id)
@@ -78,6 +81,11 @@ static inline void bpf_lsm_find_cgroup_shim(const struct bpf_prog *prog, { } +static inline int bpf_lsm_get_retval_range (const struct bpf_prog *prog, +struct bpf_retval_range *range) +{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_BPF_LSM */ #endif /* _LINUX_BPF_LSM_H */
kernel/bpf/bpf_lsm.c +33 -1
@@ -11,7 +11,6 @@#include <linux/lsm_hooks.h> #include <linux/bpf_lsm.h> #include <linux/kallsyms.h> -#include <linux/bpf_verifier.h> #include <net/bpf_sk_storage.h> #include <linux/bpf_local_storage.h> #include <linux/btf_ids.h>
@@ -389,3 +388,36 @@ const struct bpf_verifier_ops lsm_verifier_ops = { .get_func_proto = bpf_lsm_func_proto, .is_valid_access = btf_ctx_access, }; + +/* hooks return 0 or 1 */ +BTF_SET_START(bool_lsm_hooks) +#ifdef CONFIG_SECURITY_NETWORK_XFRM +BTF_ID(func, bpf_lsm_xfrm_state_pol_flow_match) +#endif +#ifdef CONFIG_AUDIT +BTF_ID(func, bpf_lsm_audit_rule_known) +#endif +BTF_ID(func, bpf_lsm_inode_xattr_skipcap) +BTF_SET_END (bool_lsm_hooks) + +int bpf_lsm_get_retval_range(const struct bpf_prog *prog, +struct bpf_retval_range *retval_range) +{ +/* no return value range for void hooks */ +if (!prog->aux->attach_func_proto->type) +return -EINVAL ; + +if (btf_id_set_contains (&bool_lsm_hooks, prog->aux->attach_btf_id)) { + retval_range->minval =0 ; + retval_range->maxval =1 ; + }else { +/* All other available LSM hooks, except task_prctl, return 0 +* on success and negative error code on failure. +* To keep things simple, we only allow bpf progs to return 0 +* or negative errno for task_prctl too. +*/ + retval_range->minval = -MAX_ERRNO ; + retval_range->maxval =0 ; + } +return 0 ; +}
kernel/bpf/btf.c +4 -1
@@ -6250,8 +6250,11 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,if (arg == nr_args) {switch (prog->expected_attach_type) { -case BPF_LSM_CGROUP :case BPF_LSM_MAC : +/* mark we are accessing the return value */ + info->is_retval = true; + fallthrough; +case BPF_LSM_CGROUP :case BPF_TRACE_FEXIT :/* When LSM programs are attached to void LSM hooks * they use FEXIT trampolines and when attached to
kernel/bpf/verifier.c +51 -9
112 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 231/634 bpf: Fix compare error in function retval_range_within
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Kuohai <[email protected]>
[ Upstream commit 763aa759d3b2c4f95b11855e3d37b860860107e2 ]
After checking lsm hook return range in verifier, the test case "test_progs -t test_lsm" failed, and the failure log says:
libbpf: prog 'test_int_hook': BPF program load failed: Invalid argument
libbpf: prog 'test_int_hook': -- BEGIN PROG LOAD LOG --
0: R1=ctx() R10=fp0
; int BPF_PROG(test_int_hook, struct vm_area_struct *vma, @ lsm.c:89
0: (79) r0 = *(u64 *)(r1 +24) ; R0_w=scalar(smin=smin32=-4095,smax=smax32=0) R1=ctx()
[...]
24: (b4) w0 = -1 ; R0_w=0xffffffff
; int BPF_PROG(test_int_hook, struct vm_area_struct *vma, @ lsm.c:89
25: (95) exit
At program exit the register R0 has smin=4294967295 smax=4294967295 should have been in [-4095, 0]
It can be seen that instruction "w0 = -1" zero extended -1 to 64-bit register r0, setting both smin and smax values of r0 to 4294967295. This resulted in a false reject when r0 was checked with range [-4095, 0].
Given bpf lsm does not return 64-bit values, this patch fixes it by changing the compare between r0 and return range from 64-bit operation to 32-bit operation for bpf lsm.
--- kernel/bpf/verifier.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
kernel/bpf/verifier.c +11 -5
@@ -9952,9 +9952,13 @@ static bool in_rbtree_lock_required_cb(struct bpf_verifier_env *env)return is_rbtree_lock_required_kfunc (kfunc_btf_id); } -static bool retval_range_within (struct bpf_retval_range range,const struct bpf_reg_state *reg) +static bool retval_range_within (struct bpf_retval_range range,const struct bpf_reg_state *reg, +bool return_32bit) { -return range.minval <= reg->smin_value && reg->smax_value <= range.maxval; +if (return_32bit) +return range.minval <= reg->s32_min_value && reg->s32_max_value <= range.maxval; +else +return range.minval <= reg->smin_value && reg->smax_value <= range.maxval; }static int prepare_func_exit (struct bpf_verifier_env *env,int *insn_idx)
@@ -9991,8 +9995,8 @@ static int prepare_func_exit(struct bpf_verifier_env *env, int *insn_idx)if (err)return err; -/* enforce R0 return value range */ -if (!retval_range_within (callee->callback_ret_range, r0)) { +/* enforce R0 return value range, and bpf_callback_t returns 64bit */ +if (!retval_range_within (callee->callback_ret_range, r0, false)) {verbose_invalid_scalar (env, r0, callee->callback_ret_range,"At callback return" ,"R0" );return -EINVAL ;
@@ -15613,6 +15617,7 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const charint err;struct bpf_func_state *frame = env->cur_state->frame[0 ];const bool is_subprog = frame->subprogno; +bool return_32bit = false;/* LSM and struct_ops func-ptr's return type could be "void" */ if (!is_subprog || frame->in_exception_callback_fn) {
@@ -15724,6 +15729,7 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char/* no restricted range, any return value is allowed */ if (range.minval ==S32_MIN && range.maxval ==S32_MAX )return 0 ; + return_32bit = true; }else if (!env->prog->aux->attach_func_proto->type) {/* Make sure programs that attach to void * hooks don't try to modify return value.
@@ -15754,7 +15760,7 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const charif (err)return err; -if (!retval_range_within (range, reg)) { +if (!retval_range_within (range, reg, return_32bit)) {verbose_invalid_scalar (env, reg, range, exit_ctx, reg_name); if (!is_subprog && prog->expected_attach_type == BPF_LSM_CGROUP &&
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 232/634 selftests/bpf: Workaround strict bpf_lsm return value check.
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
[ Upstream commit aa8ebb270c66cea1f56a25d0f938036e91ad085a ]
test_progs-no_alu32 -t libbpf_get_fd_by_id_opts is being rejected by the verifier with the following error due to compiler optimization:
6: (67) r0 <<= 62 ; R0_w=scalar(smax=0x4000000000000000,umax=0xc000000000000000,smin32=0,smax32=umax32=0,var_off=(0x0; 0xc000000000000000))
7: (c7) r0 s>>= 63 ; R0_w=scalar(smin=smin32=-1,smax=smax32=0)
; @ test_libbpf_get_fd_by_id_opts.c:0
8: (57) r0 &= -13 ; R0_w=scalar(smax=0x7ffffffffffffff3,umax=0xfffffffffffffff3,smax32=0x7ffffff3,umax32=0xfffffff3,var_off=(0x0; 0xfffffffffffffff3))
; int BPF_PROG(check_access, struct bpf_map *map, fmode_t fmode) @ test_libbpf_get_fd_by_id_opts.c:27 9: (95) exit
At program exit the register R0 has smax=9223372036854775795 should have been in [-4095, 0]
Workaround by adding barrier().
Eventually the verifier will be able to recognize it.
--- .../testing/selftests/bpf/progs/test_libbpf_get_fd_by_id_opts.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/progs/test_libbpf_get_fd_by_id_opts.c +1 -0
@@ -31,6 +31,7 @@ int BPF_PROG(check_access, struct bpf_map *map, fmode_t fmode)if (fmode &FMODE_WRITE )return -EACCES ; +barrier ();return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 233/634 selftests/bpf: Fix error linking uprobe_multi on mips
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit a5f40d596bff182b4b47547712f540885e8fb17b ]
Linking uprobe_multi.c on mips64el fails due to relocation overflows, when the GOT entries required exceeds the default maximum. Add a specific CFLAGS (-mxgot) for uprobe_multi.c on MIPS that allows using a larger GOT and avoids errors such as:
/tmp/ccBTNQzv.o: in function `bench':
uprobe_multi.c:49:(.text+0x1d7720): relocation truncated to fit: R_MIPS_GOT_DISP against uprobe_multi_func_08188' uprobe_multi.c:49:(.text+0x1d7730): relocation truncated to fit: R_MIPS_GOT_DISP against uprobe_multi_func_08189'
...
collect2: error: ld returned 1 exit status
--- tools/testing/selftests/bpf/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/Makefile +2 -0
@@ -762,6 +762,8 @@ $(OUTPUT)/veristat: $(OUTPUT)/veristat.o $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@ +# Linking uprobe_multi can fail due to relocation overflows on mips. +$(OUTPUT)/uprobe_multi: CFLAGS += $(if $(filter mips, $(ARCH)),-mxgot) $(OUTPUT)/uprobe_multi: uprobe_multi.c $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) -O0 $(LDFLAGS) $^ $(LDLIBS) -o $@
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 234/634 selftests/bpf: Fix wrong binary in Makefile log output
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 3ece93a4087b2db7b99ebb2412bd60cf26bbbb51 ]
Make log output incorrectly shows 'test_maps' as the binary name for every 'CLNG-BPF' build step, apparently picking up the last value defined for the $(TRUNNER_BINARY) variable. Update the 'CLANG_BPF_BUILD_RULE' variants to fix this confusing output.
Current output:
CLNG-BPF [test_maps] access_map_in_map.bpf.o GEN-SKEL [test_progs] access_map_in_map.skel.h
...
CLNG-BPF [test_maps] access_map_in_map.bpf.o GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
...
CLNG-BPF [test_maps] access_map_in_map.bpf.o GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h
After fix:
CLNG-BPF [test_progs] access_map_in_map.bpf.o GEN-SKEL [test_progs] access_map_in_map.skel.h
...
CLNG-BPF [test_progs-no_alu32] access_map_in_map.bpf.o GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
...
CLNG-BPF [test_progs-cpuv4] access_map_in_map.bpf.o GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h
--- tools/testing/selftests/bpf/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/Makefile +6 -5
@@ -427,23 +427,24 @@ $(OUTPUT)/cgroup_getset_retval_hooks.o: cgroup_getset_retval_hooks.h # $1 - input .c file # $2 - output .o file # $3 - CFLAGS +# $4 - binary name define CLANG_BPF_BUILD_RULE - $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2) + $(call msg,CLNG-BPF,$4,$2) $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v3 -o $2 endef # Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32 define CLANG_NOALU32_BPF_BUILD_RULE - $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2) + $(call msg,CLNG-BPF,$4,$2) $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v2 -o $2 endef # Similar to CLANG_BPF_BUILD_RULE, but with cpu-v4 define CLANG_CPUV4_BPF_BUILD_RULE - $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2) + $(call msg,CLNG-BPF,$4,$2) $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v4 -o $2 endef # Build BPF object using GCC define GCC_BPF_BUILD_RULE - $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2) + $(call msg,GCC-BPF,$4,$2) $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2 endef
@@ -535,7 +536,7 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o: \ $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \ $(TRUNNER_BPF_CFLAGS) \ $$($$<-CFLAGS) \ - $$($$<-$2-CFLAGS)) + $$($$<-$2-CFLAGS),$(TRUNNER_BINARY)) $(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT) $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 235/634 tools/runqslower: Fix LDFLAGS and add LDLIBS support
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit f86601c3661946721e8f260bdd812b759854ac22 ]
Actually use previously defined LDFLAGS during build and add support for LDLIBS to link extra standalone libraries e.g. 'argp' which is not provided by musl libc.
--- tools/bpf/runqslower/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/bpf/runqslower/Makefile +2 -1
@@ -15,6 +15,7 @@ INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../include/uapi) CFLAGS := -g -Wall $(CLANG_CROSS_FLAGS) CFLAGS += $(EXTRA_CFLAGS) LDFLAGS += $(EXTRA_LDFLAGS) +LDLIBS += -lelf -lz # Try to detect best kernel BTF source KERNEL_REL := $(shell uname -r)
@@ -51,7 +52,7 @@ clean: libbpf_hdrs: $(BPFOBJ) $(OUTPUT)/runqslower: $(OUTPUT)/runqslower.o $(BPFOBJ) - $(QUIET_LINK)$(CC) $(CFLAGS) $^ -lelf -lz -o $@ + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h \ $(OUTPUT)/runqslower.bpf.o | libbpf_hdrs
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 236/634 bpf: Fail verification for sign-extension of packet data/data_end/data_meta
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 92de36080c93296ef9005690705cba260b9bd68a ]
syzbot reported a kernel crash due to
commit 1f1e864b6555 ("bpf: Handle sign-extenstin ctx member accesses").
The reason is due to sign-extension of 32-bit load for
packet data/data_end/data_meta uapi field.
The original code looks like:
r2 = *(s32 *)(r1 + 76) /* load __sk_buff->data */
r3 = *(u32 *)(r1 + 80) /* load __sk_buff->data_end */
r0 = r2
r0 += 8
if r3 > r0 goto +1
...Note that __sk_buff->data load has 32-bit sign extension.
After verification and convert_ctx_accesses(), the final asm code looks like:
r2 = *(u64 *)(r1 +208)
r2 = (s32)r2
r3 = *(u64 *)(r1 +80)
r0 = r2
r0 += 8
if r3 > r0 goto pc+1
...Note that 'r2 = (s32)r2' may make the kernel __sk_buff->data address invalid which may cause runtime failure.
Currently, in C code, typically we have
void *data = (void *)(long)skb->data;
void *data_end = (void *)(long)skb->data_end;
...
and it will generate
r2 = *(u64 *)(r1 +208)
r3 = *(u64 *)(r1 +80)
r0 = r2
r0 += 8
if r3 > r0 goto pc+1If we allow sign-extension,
void *data = (void *)(long)(int)skb->data;
void *data_end = (void *)(long)skb->data_end;
...
the generated code looks like
r2 = *(u64 *)(r1 +208)
r2 <<= 32
r2 s>>= 32
r3 = *(u64 *)(r1 +80)
r0 = r2
r0 += 8
if r3 > r0 goto pc+1and this will cause verification failure since "r2 <<= 32" is not allowed as "r2" is a packet pointer.
To fix this issue for case
r2 = *(s32 *)(r1 + 76) /* load __sk_buff->data */
this patch added additional checking in is_valid_access() callback function for packet data/data_end/data_meta access. If those accesses are with sign-extenstion, the verification will fail.
[1] https://lore.kernel.org/bpf/[email protected]/
--- include/linux/bpf.h | 1 + kernel/bpf/verifier.c | 5 +++-- net/core/filter.c | 21 ++++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-)
include/linux/bpf.h +1 -0
@@ -919,6 +919,7 @@ static_assert(__BPF_REG_TYPE_MAX <= BPF_BASE_TYPE_LIMIT);*/ struct bpf_insn_access_aux { enum bpf_reg_type reg_type; + bool is_ldsx; union { int ctx_field_size; struct {
kernel/bpf/verifier.c +3 -2
@@ -5594,12 +5594,13 @@ static int check_packet_access(struct bpf_verifier_env *env, u32 regno, int off,/* check access to 'struct bpf_context' fields. Supports fixed offsets only */ static int check_ctx_access (struct bpf_verifier_env *env,int insn_idx,int off,int size,enum bpf_access_type t,enum bpf_reg_type *reg_type, -struct btf **btf,u32 *btf_id,bool *is_retval) +struct btf **btf,u32 *btf_id,bool *is_retval,bool is_ldsx) {struct bpf_insn_access_aux info = { .reg_type = *reg_type, .log = &env->log, .is_retval = false, + .is_ldsx = is_ldsx, }; if (env->ops->is_valid_access &&
@@ -6913,7 +6914,7 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regnreturn err; err =check_ctx_access (env, insn_idx, off, size, t, ®_type, &btf, - &btf_id, &is_retval); + &btf_id, &is_retval, is_ldsx);if (err)verbose_linfo (env, insn_idx,"; " );if (!err && t ==BPF_READ && value_regno >=0 ) {
net/core/filter.c +16 -5
@@ -8568,13 +8568,16 @@ static bool bpf_skb_is_valid_access(int off, int size, enum bpf_access_type type if (off + size > offsetofend(struct __sk_buff, cb[4]))return false;break ; + case bpf_ctx_range(struct __sk_buff, data): + case bpf_ctx_range(struct __sk_buff, data_meta): + case bpf_ctx_range(struct __sk_buff, data_end): +if (info->is_ldsx || size != size_default) +return false; +break ; case bpf_ctx_range_till(struct __sk_buff, remote_ip6[0], remote_ip6[3]): case bpf_ctx_range_till(struct __sk_buff, local_ip6[0], local_ip6[3]): case bpf_ctx_range_till(struct __sk_buff, remote_ip4, remote_ip4): case bpf_ctx_range_till(struct __sk_buff, local_ip4, local_ip4): - case bpf_ctx_range(struct __sk_buff, data): - case bpf_ctx_range(struct __sk_buff, data_meta): - case bpf_ctx_range(struct __sk_buff, data_end):if (size != size_default)return false;break ;
@@ -9018,6 +9021,14 @@ static bool xdp_is_valid_access(int off, int size, } }return false; + }else { +switch (off) { +case offsetof(struct xdp_md , data_meta): +case offsetof(struct xdp_md , data): +case offsetof(struct xdp_md , data_end): +if (info->is_ldsx) +return false; + } }switch (off) {
@@ -9343,12 +9354,12 @@ static bool flow_dissector_is_valid_access(int off, int size,switch (off) { case bpf_ctx_range(struct __sk_buff, data): -if (size != size_default) +if (info->is_ldsx || size != size_default)return false; info->reg_type =PTR_TO_PACKET ;return true; case bpf_ctx_range(struct __sk_buff, data_end): -if (size != size_default) +if (info->is_ldsx || size != size_default)return false; info->reg_type =PTR_TO_PACKET_END ;return true;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 237/634 selftests/bpf: Use pid_t consistently in test_progs.c
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit ec4fe2f0fa12fd2d0115df7e58414dc26899cc5e ]
Use pid_t rather than __pid_t when allocating memory for 'worker_pids' in 'struct test_env', as this is its declared type and also avoids compile errors seen building against musl libc on mipsel64:
test_progs.c:1738:49: error: '__pid_t' undeclared (first use in this function); did you mean 'pid_t'?
1738 | env.worker_pids = calloc(sizeof(__pid_t), env.workers);
| ^~~~~~~
| pid_ttest_progs.c:1738:49: note: each undeclared identifier is reported only once for each function it appears in
--- tools/testing/selftests/bpf/test_progs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_progs.c +1 -1
@@ -1731,7 +1731,7 @@ int main(int argc, char **argv)/* launch workers if requested */ env.worker_id =-1 ;/* main process */ if (env.workers) { - env.worker_pids =calloc (sizeof (__pid_t), env.workers); + env.worker_pids =calloc (sizeof (pid_t), env.workers); env.worker_socks =calloc (sizeof (int ), env.workers);if (env.debug)fprintf (stdout,"Launching %d workers.\n" , env.workers);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 238/634 selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit d393f9479d4aaab0fa4c3caf513f28685e831f13 ]
Cast 'rlim_t' argument to match expected type of printf() format and avoid compile errors seen building for mips64el/musl-libc:
In file included from map_tests/sk_storage_map.c:20:
map_tests/sk_storage_map.c: In function 'test_sk_storage_map_stress_free':
map_tests/sk_storage_map.c:414:56: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'rlim_t' {aka 'long long unsigned int'} [-Werror=format=]
414 | CHECK(err, "setrlimit(RLIMIT_NOFILE)", "rlim_new:%lu errno:%d",
| ^~~~~~~~~~~~~~~~~~~~~~~
415 | rlim_new.rlim_cur, errno);
| ~~~~~~~~~~~~~~~~~
| |
| rlim_t {aka long long unsigned int}
./test_maps.h:12:24: note: in definition of macro 'CHECK'
12 | printf(format); \
| ^~~~~~
map_tests/sk_storage_map.c:414:68: note: format string is defined here
414 | CHECK(err, "setrlimit(RLIMIT_NOFILE)", "rlim_new:%lu errno:%d",
| ~~^
| |
| long unsigned int
| %llucc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/map_tests/sk_storage_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/map_tests/sk_storage_map.c +1 -1
@@ -412,7 +412,7 @@ static void test_sk_storage_map_stress_free(void) rlim_new.rlim_max = rlim_new.rlim_cur +128 ; err =setrlimit (RLIMIT_NOFILE , &rlim_new);CHECK (err,"setrlimit(RLIMIT_NOFILE)" ,"rlim_new:%lu errno:%d" , - rlim_new.rlim_cur, errno); + (unsigned long ) rlim_new.rlim_cur, errno); } err =do_sk_storage_map_stress_free ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 239/634 selftests/bpf: Fix error compiling bpf_iter_setsockopt.c with musl libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 7b10f0c227ce3fa055d601f058dc411092a62a78 ]
Existing code calls getsockname() with a 'struct sockaddr_in6 *' argument where a 'struct sockaddr *' argument is declared, yielding compile errors when building for mips64el/musl-libc:
bpf_iter_setsockopt.c: In function 'get_local_port':
bpf_iter_setsockopt.c:98:30: error: passing argument 2 of 'getsockname' from incompatible pointer type [-Werror=incompatible-pointer-types]
98 | if (!getsockname(fd, &addr, &addrlen))
| ^~~~~
| |
| struct sockaddr_in6 *
In file included from .../netinet/in.h:10,
from .../arpa/inet.h:9,
from ./test_progs.h:17,
from bpf_iter_setsockopt.c:5:
.../sys/socket.h:391:23: note: expected 'struct sockaddr * restrict' but argument is of type 'struct sockaddr_in6 *'
391 | int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
| ^cc1: all warnings being treated as errors
This compiled under glibc only because the argument is declared to be a "funky" transparent union which includes both types above. Explicitly cast the argument to allow compiling for both musl and glibc.
--- tools/testing/selftests/bpf/prog_tests/bpf_iter_setsockopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/bpf_iter_setsockopt.c +1 -1
@@ -95,7 +95,7 @@ static unsigned short get_local_port(int fd)struct sockaddr_in6 addr;socklen_t addrlen =sizeof (addr); -if (!getsockname (fd, &addr, &addrlen)) +if (!getsockname (fd, (struct sockaddr *)&addr, &addrlen))return ntohs (addr.sin6_port);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 240/634 selftests/bpf: Drop unneeded error.h includes
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 69f409469c9b1515a5db40d5a36fda372376fa2d ]
The addition of general support for unprivileged tests in test_loader.c breaks building test_verifier on non-glibc (e.g. musl) systems, due to the inclusion of glibc extension '<error.h>' in 'unpriv_helpers.c'. However, the header is actually not needed, so remove it to restore building.
Similarly for sk_lookup.c and flow_dissector.c, error.h is not necessary and causes problems, so drop them.
--- tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 1 - tools/testing/selftests/bpf/prog_tests/sk_lookup.c | 1 - tools/testing/selftests/bpf/unpriv_helpers.c | 1 - 3 files changed, 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/flow_dissector.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <test_progs.h> #include <network_helpers.h> -#include <error.h> #include <linux/if_tun.h> #include <sys/uio.h>
tools/testing/selftests/bpf/prog_tests/sk_lookup.c +0 -1
@@ -18,7 +18,6 @@#include <arpa/inet.h> #include <assert.h> #include <errno.h> -#include <error.h> #include <fcntl.h> #include <sched.h> #include <stdio.h>
tools/testing/selftests/bpf/unpriv_helpers.c +0 -1
@@ -2,7 +2,6 @@#include <stdbool.h> #include <stdlib.h> -#include <error.h> #include <stdio.h> #include <string.h> #include <unistd.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 241/634 selftests/bpf: Fix missing ARRAY_SIZE() definition in bench.c
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit d44c93fc2f5a0c47b23fa03d374e45259abd92d2 ]
Add a "bpf_util.h" include to avoid the following error seen compiling for mips64el with musl libc:
bench.c: In function 'find_benchmark':
bench.c:590:25: error: implicit declaration of function 'ARRAY_SIZE' [-Werror=implicit-function-declaration]
590 | for (i = 0; i < ARRAY_SIZE(benchs); i++) {
| ^~~~~~~~~~cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/bench.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/bench.c +1 -0
@@ -10,6 +10,7 @@#include <sys/sysinfo.h> #include <signal.h> #include "bench.h" +#include "bpf_util.h" #include "testing_helpers.h" struct env env = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 242/634 selftests/bpf: Fix missing UINT_MAX definitions in benchmarks
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit a2c155131b710959beb508ca6a54769b6b1bd488 ]
Include <limits.h> in 'bench.h' to provide a UINT_MAX definition and avoid multiple compile errors against mips64el/musl-libc like:
benchs/bench_local_storage.c: In function 'parse_arg':
benchs/bench_local_storage.c:40:38: error: 'UINT_MAX' undeclared (first use in this function)
40 | if (ret < 1 || ret > UINT_MAX) {
| ^~~~~~~~
benchs/bench_local_storage.c:11:1: note: 'UINT_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'?
10 | #include <test_btf.h>
+++ |+#include <limits.h>
11 |seen with bench_local_storage.c, bench_local_storage_rcu_tasks_trace.c, and bench_bpf_hashmap_lookup.c.
--- tools/testing/selftests/bpf/bench.h | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/bench.h +1 -0
@@ -10,6 +10,7 @@#include <math.h> #include <time.h> #include <sys/syscall.h> +#include <limits.h> struct cpu_set {bool *cpus;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 243/634 selftests/bpf: Fix missing BUILD_BUG_ON() declaration
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 6495eb79ca7d15bd87c38d77307e8f9b6b7bf4ef ]
Explicitly include '<linux/build_bug.h>' to fix errors seen compiling with gcc targeting mips64el/musl-libc:
user_ringbuf.c: In function 'test_user_ringbuf_loop':
user_ringbuf.c:426:9: error: implicit declaration of function 'BUILD_BUG_ON' [-Werror=implicit-function-declaration]
426 | BUILD_BUG_ON(total_samples <= c_max_entries);
| ^~~~~~~~~~~~cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +1 -0
@@ -4,6 +4,7 @@#define _GNU_SOURCE#include <linux/compiler.h> #include <linux/ring_buffer.h> +#include <linux/build_bug.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 244/634 selftests/bpf: Fix include of <sys/fcntl.h>
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 21f0b0af977203220ad58aff95e372151288ec47 ]
Update ns_current_pid_tgid.c to use '#include <fcntl.h>' and avoid compile error against mips64el/musl libc:
In file included from .../prog_tests/ns_current_pid_tgid.c:14:
.../include/sys/fcntl.h:1:2: error: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Werror=cpp]
1 | #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
| ^~~~~~~
cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c +1 -1
@@ -11,7 +11,7 @@#include <sched.h> #include <sys/wait.h> #include <sys/mount.h> -#include <sys/fcntl.h> +#include <fcntl.h> #include "network_helpers.h" #define STACK_SIZE (1024 * 1024)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 245/634 selftests/bpf: Fix compiling parse_tcp_hdr_opt.c with musl-libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 4c329b99ef9c118343379bde9f97e8ce5cac9fc9 ]
The GNU version of 'struct tcphdr', with members 'doff' and 'urg_ptr', is not exposed by musl headers unless _GNU_SOURCE is defined.
Add this definition to fix errors seen compiling for mips64el/musl-libc:
parse_tcp_hdr_opt.c:18:21: error: 'struct tcphdr' has no member named 'urg_ptr'
18 | .pk6_v6.tcp.urg_ptr = 123,
| ^~~~~~~
parse_tcp_hdr_opt.c:19:21: error: 'struct tcphdr' has no member named 'doff'
19 | .pk6_v6.tcp.doff = 9, /* 16 bytes of options */
| ^~~~--- tools/testing/selftests/bpf/prog_tests/parse_tcp_hdr_opt.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/parse_tcp_hdr_opt.c +1 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include <network_helpers.h> #include "test_parse_tcp_hdr_opt.skel.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 246/634 selftests/bpf: Fix compiling kfree_skb.c with musl-libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit bae9a5ce7d3a9b3a9e07b31ab9e9c58450e3e9fd ]
The GNU version of 'struct tcphdr' with member 'doff' is not exposed by musl headers unless _GNU_SOURCE is defined. Add this definition to fix errors seen compiling for mips64el/musl-libc:
In file included from kfree_skb.c:2:
kfree_skb.c: In function 'on_sample':
kfree_skb.c:45:30: error: 'struct tcphdr' has no member named 'doff'
45 | if (CHECK(pkt_v6->tcp.doff != 5, "check_tcp",
| ^--- tools/testing/selftests/bpf/prog_tests/kfree_skb.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/kfree_skb.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include <network_helpers.h> #include "kfree_skb.skel.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 247/634 selftests/bpf: Fix compiling flow_dissector.c with musl-libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 5e4c43bcb85973243d7274e0058b6e8f5810e4f7 ]
The GNU version of 'struct tcphdr' has members 'doff', 'source' and 'dest', which are not exposed by musl libc headers unless _GNU_SOURCE is defined.
Add this definition to fix errors seen compiling for mips64el/musl-libc:
flow_dissector.c:118:30: error: 'struct tcphdr' has no member named 'doff'
118 | .tcp.doff = 5,
| ^~~~
flow_dissector.c:119:30: error: 'struct tcphdr' has no member named 'source'
119 | .tcp.source = 80,
| ^~~~~~
flow_dissector.c:120:30: error: 'struct tcphdr' has no member named 'dest'
120 | .tcp.dest = 8080,
| ^~~~--- tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/flow_dissector.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include <network_helpers.h> #include <linux/if_tun.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 248/634 selftests/bpf: Fix compiling tcp_rtt.c with musl-libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 18826fb0b79c3c3cd1fe765d85f9c6f1a902c722 ]
The GNU version of 'struct tcp_info' in 'netinet/tcp.h' is not exposed by musl headers unless _GNU_SOURCE is defined.
Add this definition to fix errors seen compiling for mips64el/musl-libc:
tcp_rtt.c: In function 'wait_for_ack':
tcp_rtt.c:24:25: error: storage size of 'info' isn't known
24 | struct tcp_info info;
| ^~~~ tcp_rtt.c:24:25: error: unused variable 'info' [-Werror=unused-variable]
cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/prog_tests/tcp_rtt.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/tcp_rtt.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include "cgroup_helpers.h" #include "network_helpers.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 249/634 selftests/bpf: Fix compiling core_reloc.c with musl-libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit debfa4f628f271f72933bf38d581cc53cfe1def5 ]
The type 'loff_t' is a GNU extension and not exposed by the musl 'fcntl.h' header unless _GNU_SOURCE is defined. Add this definition to fix errors seen compiling for mips64el/musl-libc:
In file included from tools/testing/selftests/bpf/prog_tests/core_reloc.c:4:
./bpf_testmod/bpf_testmod.h:10:9: error: unknown type name 'loff_t'
10 | loff_t off;
| ^~~~~~
./bpf_testmod/bpf_testmod.h:16:9: error: unknown type name 'loff_t'
16 | loff_t off;
| ^~~~~~--- tools/testing/selftests/bpf/prog_tests/core_reloc.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/core_reloc.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#define _GNU_SOURCE#include <test_progs.h> #include "progs/core_reloc_types.h" #include "bpf_testmod/bpf_testmod.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 250/634 selftests/bpf: Fix errors compiling lwt_redirect.c with musl libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 27c4797ce51c8dd51e35e68e9024a892f62d78b2 ]
Remove a redundant include of '<linux/icmp.h>' which is already provided in 'lwt_helpers.h'. This avoids errors seen compiling for mips64el/musl-libc:
In file included from .../arpa/inet.h:9,
from lwt_redirect.c:51:
.../netinet/in.h:23:8: error: redefinition of 'struct in6_addr'
23 | struct in6_addr {
| ^~~~~~~~
In file included from .../linux/icmp.h:24,
from lwt_redirect.c:50:
.../linux/in6.h:33:8: note: originally defined here
33 | struct in6_addr {
| ^~~~~~~~
.../netinet/in.h:34:8: error: redefinition of 'struct sockaddr_in6'
34 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../linux/in6.h:50:8: note: originally defined here
50 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../netinet/in.h:42:8: error: redefinition of 'struct ipv6_mreq'
42 | struct ipv6_mreq {
| ^~~~~~~~~
.../linux/in6.h:60:8: note: originally defined here
60 | struct ipv6_mreq {
| ^~~~~~~~~--- tools/testing/selftests/bpf/prog_tests/lwt_redirect.c | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/lwt_redirect.c +0 -1
@@ -47,7 +47,6 @@#include <linux/if_ether.h> #include <linux/if_packet.h> #include <linux/if_tun.h> -#include <linux/icmp.h> #include <arpa/inet.h> #include <unistd.h> #include <errno.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 251/634 selftests/bpf: Fix errors compiling decap_sanity.c with musl libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 1b00f355130a5dfc38a01ad02458ae2cb2ebe609 ]
Remove a redundant include of '<linux/in6.h>', whose needed definitions are already provided by 'test_progs.h'. This avoids errors seen compiling for mips64el/musl-libc:
In file included from .../arpa/inet.h:9,
from ./test_progs.h:17,
from prog_tests/decap_sanity.c:9:
.../netinet/in.h:23:8: error: redefinition of 'struct in6_addr'
23 | struct in6_addr {
| ^~~~~~~~
In file included from decap_sanity.c:7:
.../linux/in6.h:33:8: note: originally defined here
33 | struct in6_addr {
| ^~~~~~~~
.../netinet/in.h:34:8: error: redefinition of 'struct sockaddr_in6'
34 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../linux/in6.h:50:8: note: originally defined here
50 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../netinet/in.h:42:8: error: redefinition of 'struct ipv6_mreq'
42 | struct ipv6_mreq {
| ^~~~~~~~~
.../linux/in6.h:60:8: note: originally defined here
60 | struct ipv6_mreq {
| ^~~~~~~~~--- tools/testing/selftests/bpf/prog_tests/decap_sanity.c | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/decap_sanity.c +0 -1
@@ -4,7 +4,6 @@#include <sys/types.h> #include <sys/socket.h> #include <net/if.h> -#include <linux/in6.h> #include "test_progs.h" #include "network_helpers.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 252/634 selftests/bpf: Fix errors compiling crypto_sanity.c with musl libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 9822be702fe6e1c3e0933ef4b68a8c56683d930d ]
Remove a redundant include of '<linux/in6.h>', whose needed definitions are already provided by 'test_progs.h'. This avoids errors seen compiling for mips64el/musl-libc:
In file included from .../arpa/inet.h:9,
from ./test_progs.h:17,
from prog_tests/crypto_sanity.c:10:
.../netinet/in.h:23:8: error: redefinition of 'struct in6_addr'
23 | struct in6_addr {
| ^~~~~~~~
In file included from crypto_sanity.c:7:
.../linux/in6.h:33:8: note: originally defined here
33 | struct in6_addr {
| ^~~~~~~~
.../netinet/in.h:34:8: error: redefinition of 'struct sockaddr_in6'
34 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../linux/in6.h:50:8: note: originally defined here
50 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../netinet/in.h:42:8: error: redefinition of 'struct ipv6_mreq'
42 | struct ipv6_mreq {
| ^~~~~~~~~
.../linux/in6.h:60:8: note: originally defined here
60 | struct ipv6_mreq {
| ^~~~~~~~~--- tools/testing/selftests/bpf/prog_tests/crypto_sanity.c | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/crypto_sanity.c +0 -1
@@ -4,7 +4,6 @@#include <sys/types.h> #include <sys/socket.h> #include <net/if.h> -#include <linux/in6.h> #include <linux/if_alg.h> #include "test_progs.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 253/634 selftests/bpf: Fix errors compiling cg_storage_multi.h with musl libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 730561d3c08d4a327cceaabf11365958a1c00cec ]
Remove a redundant include of '<asm/types.h>', whose needed definitions are already included (via '<linux/types.h>') in cg_storage_multi_egress_only.c, cg_storage_multi_isolated.c, and cg_storage_multi_shared.c. This avoids redefinition errors seen compiling for mips64el/musl-libc like:
In file included from progs/cg_storage_multi_egress_only.c:13:
In file included from progs/cg_storage_multi.h:6:
In file included from /usr/mips64el-linux-gnuabi64/include/asm/types.h:23:
/usr/include/asm-generic/int-l64.h:29:25: error: typedef redefinition with different types ('long' vs 'long long')
29 | typedef __signed__ long __s64;
| ^
/usr/include/asm-generic/int-ll64.h:30:44: note: previous definition is here
30 | __extension__ typedef __signed__ long long __s64;
| ^--- tools/testing/selftests/bpf/progs/cg_storage_multi.h | 2 -- 1 file changed, 2 deletions(-)
tools/testing/selftests/bpf/progs/cg_storage_multi.h +0 -2
@@ -3,8 +3,6 @@ #ifndef __PROGS_CG_STORAGE_MULTI_H #define __PROGS_CG_STORAGE_MULTI_H -#include <asm/types.h> - struct cgroup_value { __u32 egress_pkts; __u32 ingress_pkts;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 254/634 libbpf: Dont take direct pointers into BTF data from st_ops
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Vernet <[email protected]>
[ Upstream commit 04a94133f1b3cccb19e056c26f056c50b4e5b3b1 ]
In struct bpf_struct_ops, we have take a pointer to a BTF type name, and a struct btf_type. This was presumably done for convenience, but can actually result in subtle and confusing bugs given that BTF data can be invalidated before a program is loaded. For example, in sched_ext, we may sometimes resize a data section after a skeleton has been opened, but before the struct_ops scheduler map has been loaded. This may cause the BTF data to be realloc'd, which can then cause a UAF when loading the program because the struct_ops map has pointers directly into the BTF data.
We're already storing the BTF type_id in struct bpf_struct_ops. Because type_id is stable, we can therefore just update the places where we were looking at those pointers to instead do the lookups we need from the type_id.
--- tools/lib/bpf/libbpf.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
tools/lib/bpf/libbpf.c +13 -10
@@ -473,8 +473,6 @@ struct bpf_program { };struct bpf_struct_ops { -const char *tname; -const struct btf_type *type;struct bpf_program **progs;__u32 *kern_func_off;/* e.g. struct tcp_congestion_ops in bpf_prog's btf format */
@@ -1059,11 +1057,14 @@ static int bpf_object_adjust_struct_ops_autoload(struct bpf_object *obj)continue ;for (j =0 ; j < obj->nr_maps; ++j) { +const struct btf_type *type; + map = &obj->maps[j];if (!bpf_map__is_struct_ops (map))continue ; - vlen =btf_vlen (map->st_ops->type); + type =btf__type_by_id (obj->btf, map->st_ops->type_id); + vlen =btf_vlen (type);for (k =0 ; k < vlen; ++k) { slot_prog = map->st_ops->progs[k];if (prog != slot_prog)
@@ -1097,8 +1098,8 @@ static int bpf_map__init_kern_struct_ops(struct bpf_map *map)int err; st_ops = map->st_ops; - type = st_ops->type; - tname = st_ops->tname; + type =btf__type_by_id (btf, st_ops->type_id); + tname =btf__name_by_offset (btf, type->name_off); err = find_struct_ops_kern_types(obj, tname, &mod_btf, &kern_type, &kern_type_id, &kern_vtype, &kern_vtype_id,
@@ -1398,8 +1399,6 @@ static int init_struct_ops_maps(struct bpf_object *obj, const char *sec_name,memcpy (st_ops->data, data->d_buf + vsi->offset, type->size); - st_ops->tname = tname; - st_ops->type = type; st_ops->type_id = type_id; pr_debug("struct_ops init: struct %s(type_id=%u) %s found at offset %u\n",
@@ -8406,11 +8405,13 @@ static int bpf_object__resolve_externs(struct bpf_object *obj,static void bpf_map_prepare_vdata (const struct bpf_map *map) { +const struct btf_type *type;struct bpf_struct_ops *st_ops;__u32 i; st_ops = map->st_ops; -for (i =0 ; i <btf_vlen (st_ops->type); i++) { + type =btf__type_by_id (map->obj->btf, st_ops->type_id); +for (i =0 ; i <btf_vlen (type); i++) {struct bpf_program *prog = st_ops->progs[i];void *kern_data;int prog_fd;
@@ -9673,6 +9674,7 @@ static struct bpf_map *find_struct_ops_map_by_offset(struct bpf_object *obj,static int bpf_object__collect_st_ops_relos (struct bpf_object *obj,Elf64_Shdr *shdr,Elf_Data *data) { +const struct btf_type *type;const struct btf_member *member;struct bpf_struct_ops *st_ops;struct bpf_program *prog;
@@ -9732,13 +9734,14 @@ static int bpf_object__collect_st_ops_relos(struct bpf_object *obj, } insn_idx = sym->st_value /BPF_INSN_SZ ; - member =find_member_by_offset (st_ops->type, moff *8 ); + type =btf__type_by_id (btf, st_ops->type_id); + member =find_member_by_offset (type, moff *8 );if (!member) {pr_warn ("struct_ops reloc %s: cannot find member at moff %u\n" , map->name, moff);return -EINVAL ; } - member_idx = member -btf_members (st_ops->type); + member_idx = member -btf_members (type); name =btf__name_by_offset (btf, member->name_off);if (!resolve_func_ptr (btf, member->type,NULL )) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 255/634 selftests/bpf: Fix arg parsing in veristat, test_progs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 03bfcda1fbc37ef34aa21d2b9e09138335afc6ee ]
Current code parses arguments with strtok_r() using a construct like
char *state = NULL;
while ((next = strtok_r(state ? NULL : input, ",", &state))) {
...
}where logic assumes the 'state' var can distinguish between first and subsequent strtok_r() calls, and adjusts parameters accordingly. However, 'state' is strictly internal context for strtok_r() and no such assumptions are supported in the man page. Moreover, the exact behaviour of 'state' depends on the libc implementation, making the above code fragile.
Indeed, invoking "./test_progs -t <test_name>" on mips64el/musl will hang, with the above code in an infinite loop.
Similarly, we see strange behaviour running 'veristat' on mips64el/musl:
$ ./veristat -e file,prog,verdict,insns -C two-ok add-failure
Can't specify more than 9 statsRewrite code using a counter to distinguish between strtok_r() calls.
--- tools/testing/selftests/bpf/testing_helpers.c | 4 ++-- tools/testing/selftests/bpf/veristat.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/testing_helpers.c +2 -2
@@ -220,13 +220,13 @@ int parse_test_list(const char *s, bool is_glob_pattern) {char *input, *state =NULL , *test_spec; -int err =0 ; +int err =0 , cnt =0 ; input =strdup (s);if (!input)return -ENOMEM ; -while ((test_spec =strtok_r (state ?NULL : input,"," , &state))) { +while ((test_spec =strtok_r (cnt++ ?NULL : input,"," , &state))) { err =insert_test (set, test_spec, is_glob_pattern);if (err)break ;
tools/testing/selftests/bpf/veristat.c +4 -4
@@ -784,13 +784,13 @@ static int parse_stat(const char *stat_name, struct stat_specs *specs)static int parse_stats (const char *stats_str,struct stat_specs *specs) {char *input, *state =NULL , *next; -int err; +int err, cnt =0 ; input =strdup (stats_str);if (!input)return -ENOMEM ; -while ((next =strtok_r (state ?NULL : input,"," , &state))) { +while ((next =strtok_r (cnt++ ?NULL : input,"," , &state))) { err =parse_stat (next, specs);if (err) {free (input);
@@ -1493,7 +1493,7 @@ static int parse_stats_csv(const char *filename, struct stat_specs *specs,while (fgets (line,sizeof (line), f)) {char *input = line, *state =NULL , *next;struct verif_stats *st =NULL ; -int col =0 ; +int col =0 , cnt =0 ;if (!header) {void *tmp;
@@ -1511,7 +1511,7 @@ static int parse_stats_csv(const char *filename, struct stat_specs *specs, *stat_cntp +=1 ; } -while ((next =strtok_r (state ?NULL : input,",\n" , &state))) { +while ((next =strtok_r (cnt++ ?NULL : input,",\n" , &state))) {if (header) {/* for the first line, set up spec stats */ err =parse_stat (next, specs);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 256/634 selftests/bpf: Fix error compiling test_lru_map.c
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit cacf2a5a78cd1f5f616eae043ebc6f024104b721 ]
Although the post-increment in macro 'CPU_SET(next++, &cpuset)' seems safe, the sequencing can raise compile errors, so move the increment outside the macro. This avoids an error seen using gcc 12.3.0 for mips64el/musl-libc:
In file included from test_lru_map.c:11:
test_lru_map.c: In function 'sched_next_online':
test_lru_map.c:129:29: error: operation on 'next' may be undefined [-Werror=sequence-point]
129 | CPU_SET(next++, &cpuset);
| ^cc1: all warnings being treated as errors
--- tools/testing/selftests/bpf/test_lru_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_lru_map.c +2 -1
@@ -126,7 +126,8 @@ static int sched_next_online(int pid, int *next_to_try)while (next < nr_cpus) {CPU_ZERO (&cpuset); -CPU_SET (next++, &cpuset); +CPU_SET (next, &cpuset); + next++;if (!sched_setaffinity (pid,sizeof (cpuset), &cpuset)) { ret =0 ;break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 257/634 selftests/bpf: Fix C++ compile error from missing _Bool type
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit aa95073fd290b5b3e45f067fa22bb25e59e1ff7c ]
While building, bpftool makes a skeleton from test_core_extern.c, which itself includes <stdbool.h> and uses the 'bool' type. However, the skeleton test_core_extern.skel.h generated *does not* include <stdbool.h> or use the 'bool' type, instead using the C-only '_Bool' type. Compiling test_cpp.cpp with g++ 12.3 for mips64el/musl-libc then fails with error:
In file included from test_cpp.cpp:9:
test_core_extern.skel.h:45:17: error: '_Bool' does not name a type
45 | _Bool CONFIG_BOOL;
| ^~~~~This was likely missed previously because glibc uses a GNU extension for <stdbool.h> with C++ (#define _Bool bool), not supported by musl libc.
Normally, a C fragment would include <stdbool.h> and use the 'bool' type, and thus cleanly work after import by C++. The ideal fix would be for 'bpftool gen skeleton' to output the correct type/include supporting C++, but in the meantime add a conditional define as above.
--- tools/testing/selftests/bpf/test_cpp.cpp | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/bpf/test_cpp.cpp +4 -0
@@ -6,6 +6,10 @@ #include <bpf/libbpf.h> #include <bpf/bpf.h> #include <bpf/btf.h> + +#ifndef _Bool +#define _Bool bool +#endif #include "test_core_extern.skel.h" #include "struct_ops_module.skel.h"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 258/634 selftests/bpf: Fix redefinition errors compiling lwt_reroute.c
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 16b795cc59528cf280abc79af3c70bda42f715b9 ]
Compiling lwt_reroute.c with GCC 12.3 for mips64el/musl-libc yields errors:
In file included from .../include/arpa/inet.h:9,
from ./test_progs.h:18,
from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:11,
from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52:
.../include/netinet/in.h:23:8: error: redefinition of 'struct in6_addr'
23 | struct in6_addr {
| ^~~~~~~~
In file included from .../include/linux/icmp.h:24,
from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:9:
.../include/linux/in6.h:33:8: note: originally defined here
33 | struct in6_addr {
| ^~~~~~~~
.../include/netinet/in.h:34:8: error: redefinition of 'struct sockaddr_in6'
34 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../include/linux/in6.h:50:8: note: originally defined here
50 | struct sockaddr_in6 {
| ^~~~~~~~~~~~
.../include/netinet/in.h:42:8: error: redefinition of 'struct ipv6_mreq'
42 | struct ipv6_mreq {
| ^~~~~~~~~
.../include/linux/in6.h:60:8: note: originally defined here
60 | struct ipv6_mreq {
| ^~~~~~~~~These errors occur because <linux/in6.h> is included before <netinet/in.h>, bypassing the Linux uapi/libc compat mechanism's partial musl support. As described in [1] and [2], fix these errors by including <netinet/in.h> in lwt_reroute.c before any uapi headers.
[1]: commit c0bace798436 ("uapi libc compat: add fallback for unsupported libcs") [2]: https://git.musl-libc.org/cgit/musl/commit/?id=04983f227238
--- tools/testing/selftests/bpf/prog_tests/lwt_reroute.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/lwt_reroute.c +1 -0
@@ -49,6 +49,7 @@* is not crashed, it is considered successful. */ #define NETNS "ns_lwt_reroute" +#include <netinet/in.h> #include "lwt_helpers.h" #include "network_helpers.h" #include <linux/net_tstamp.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 259/634 selftests/bpf: Fix compile if backtrace support missing in libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit c9a83e76b5a96801a2c7ea0a79ca77c356d8b38d ]
Include GNU <execinfo.h> header only with glibc and provide weak, stubbed backtrace functions as a fallback in test_progs.c. This allows for non-GNU replacements while avoiding compile errors (e.g. with musl libc) like:
test_progs.c:13:10: fatal error: execinfo.h: No such file or directory
13 | #include <execinfo.h> /* backtrace */
| ^~~~~~~~~~~~
test_progs.c: In function 'crash_handler':
test_progs.c:1034:14: error: implicit declaration of function 'backtrace' [-Werror=implicit-function-declaration]
1034 | sz = backtrace(bt, ARRAY_SIZE(bt));
| ^~~~~~~~~
test_progs.c:1045:9: error: implicit declaration of function 'backtrace_symbols_fd' [-Werror=implicit-function-declaration]
1045 | backtrace_symbols_fd(bt, sz, STDERR_FILENO);
| ^~~~~~~~~~~~~~~~~~~~--- tools/testing/selftests/bpf/test_progs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_progs.c +15 -1
@@ -10,7 +10,6 @@#include <sched.h> #include <signal.h> #include <string.h> -#include <execinfo.h> /* backtrace */ #include <sys/sysinfo.h> /* get_nprocs */ #include <netinet/in.h> #include <sys/select.h>
@@ -19,6 +18,21 @@#include <bpf/btf.h> #include "json_writer.h" +#ifdef __GLIBC__ +#include <execinfo.h> /* backtrace */ +#endif + +/* Default backtrace funcs if missing at link */ +__weak int backtrace (void **buffer,int size) +{ +return 0 ; +} + +__weak void backtrace_symbols_fd (void *const *buffer,int size,int fd) +{ +dprintf (fd,"<backtrace not supported>\n" ); +} +static bool verbose (void ) {return env.verbosity >VERBOSE_NONE ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 260/634 selftests/bpf: Fix error compiling tc_redirect.c with musl libc
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Ambardar <[email protected]>
[ Upstream commit 21c5f4f55da759c7444a1ef13e90b6e6f674eeeb ]
Linux 5.1 implemented 64-bit time types and related syscalls to address the Y2038 problem generally across archs. Userspace handling of Y2038 varies with the libc however. While musl libc uses 64-bit time across all 32-bit and 64-bit platforms, GNU glibc uses 64-bit time on 64-bit platforms but defaults to 32-bit time on 32-bit platforms unless they "opt-in" to 64-bit time or explicitly use 64-bit syscalls and time structures.
One specific area is the standard setsockopt() call, SO_TIMESTAMPNS option used for timestamping, and the related output 'struct timespec'. GNU glibc defaults as above, also exposing the SO_TIMESTAMPNS_NEW flag to explicitly use a 64-bit call and 'struct __kernel_timespec'. Since these are not exposed or needed with musl libc, their use in tc_redirect.c leads to compile errors building for mips64el/musl:
tc_redirect.c: In function 'rcv_tstamp':
tc_redirect.c:425:32: error: 'SO_TIMESTAMPNS_NEW' undeclared (first use in this function); did you mean 'SO_TIMESTAMPNS'?
425 | cmsg->cmsg_type == SO_TIMESTAMPNS_NEW)
| ^~~~~~~~~~~~~~~~~~
| SO_TIMESTAMPNS
tc_redirect.c:425:32: note: each undeclared identifier is reported only once for each function it appears in
tc_redirect.c: In function 'test_inet_dtime':
tc_redirect.c:491:49: error: 'SO_TIMESTAMPNS_NEW' undeclared (first use in this function); did you mean 'SO_TIMESTAMPNS'?
491 | err = setsockopt(listen_fd, SOL_SOCKET, SO_TIMESTAMPNS_NEW,
| ^~~~~~~~~~~~~~~~~~
| SO_TIMESTAMPNSHowever, using SO_TIMESTAMPNS_NEW isn't strictly needed, nor is Y2038 being explicitly tested. The timestamp checks in tc_redirect.c are simple: the packet receive timestamp is non-zero and processed/handled in less than 5 seconds.
Switch to using the standard setsockopt() call and SO_TIMESTAMPNS option to ensure compatibility across glibc and musl libc. In the worst-case, there is a 5-second window 14 years from now where tc_redirect tests may fail on 32-bit systems. However, we should reasonably expect glibc to adopt a 64-bit mandate rather than the current "opt-in" policy before the Y2038 roll-over.
--- tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/prog_tests/tc_redirect.c +6 -6
@@ -471,7 +471,7 @@ static int set_forwarding(bool enable)static int __rcv_tstamp (int fd,const char *expected,size_t s,__u64 *tstamp) { -struct __kernel_timespec pkt_ts = {}; +struct timespec pkt_ts = {};char ctl[CMSG_SPACE (sizeof (pkt_ts))];struct timespec now_ts;struct msghdr msg = {};
@@ -495,7 +495,7 @@ static int __rcv_tstamp(int fd, const char *expected, size_t s, __u64 *tstamp) cmsg =CMSG_FIRSTHDR (&msg);if (cmsg && cmsg->cmsg_level ==SOL_SOCKET && - cmsg->cmsg_type ==SO_TIMESTAMPNS_NEW ) + cmsg->cmsg_type ==SO_TIMESTAMPNS )memcpy (&pkt_ts,CMSG_DATA (cmsg),sizeof (pkt_ts)); pkt_ns = pkt_ts.tv_sec *NSEC_PER_SEC + pkt_ts.tv_nsec;
@@ -537,9 +537,9 @@ static int wait_netstamp_needed_key(void)if (!ASSERT_GE (srv_fd,0 ,"start_server" )) goto done; - err =setsockopt (srv_fd,SOL_SOCKET ,SO_TIMESTAMPNS_NEW , + err =setsockopt (srv_fd,SOL_SOCKET ,SO_TIMESTAMPNS , &opt,sizeof (opt)); -if (!ASSERT_OK (err,"setsockopt(SO_TIMESTAMPNS_NEW)" )) +if (!ASSERT_OK (err,"setsockopt(SO_TIMESTAMPNS)" )) goto done; cli_fd =connect_to_fd (srv_fd,TIMEOUT_MILLIS );
@@ -621,9 +621,9 @@ static void test_inet_dtime(int family, int type, const char *addr, __u16 port)return ;/* Ensure the kernel puts the (rcv) timestamp for all skb */ - err =setsockopt (listen_fd,SOL_SOCKET ,SO_TIMESTAMPNS_NEW , + err =setsockopt (listen_fd,SOL_SOCKET ,SO_TIMESTAMPNS , &opt,sizeof (opt)); -if (!ASSERT_OK (err,"setsockopt(SO_TIMESTAMPNS_NEW)" )) +if (!ASSERT_OK (err,"setsockopt(SO_TIMESTAMPNS)" )) goto done;if (type ==SOCK_STREAM ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 261/634 samples/bpf: Fix compilation errors with cf-protection option
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangshan Yi <[email protected]>
[ Upstream commit fdf1c728fac541891ef1aa773bfd42728626769c ]
Currently, compiling the bpf programs will result the compilation errors with the cf-protection option as follows in arm64 and loongarch64 machine when using gcc 12.3.1 and clang 17.0.6. This commit fixes the compilation errors by limited the cf-protection option only used in x86 platform.
[root@localhost linux]# make M=samples/bpf
......
CLANG-bpf samples/bpf/xdp2skb_meta_kern.o
error: option 'cf-protection=return' cannot be specified on this target
error: option 'cf-protection=branch' cannot be specified on this target 2 errors generated.
CLANG-bpf samples/bpf/syscall_tp_kern.o
error: option 'cf-protection=return' cannot be specified on this target
error: option 'cf-protection=branch' cannot be specified on this target 2 errors generated.
......
--- samples/bpf/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
samples/bpf/Makefile +5 -1
@@ -169,6 +169,10 @@ BPF_EXTRA_CFLAGS += -I$(srctree)/arch/mips/include/asm/mach-generic endif endif +ifeq ($(ARCH), x86) +BPF_EXTRA_CFLAGS += -fcf-protection +endif + TPROGS_CFLAGS += -Wall -O2 TPROGS_CFLAGS += -Wmissing-prototypes TPROGS_CFLAGS += -Wstrict-prototypes
@@ -405,7 +409,7 @@ $(obj)/%.o: $(src)/%.c -Wno-gnu-variable-sized-type-not-at-end \ -Wno-address-of-packed-member -Wno-tautological-compare \ -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \ - -fno-asynchronous-unwind-tables -fcf-protection \ + -fno-asynchronous-unwind-tables \ -I$(srctree)/samples/bpf/ -include asm_goto_workaround.h \ -O2 -emit-llvm -Xclang -disable-llvm-passes -c $< -o - | \ $(OPT) -O2 -mtriple=bpf-pc-linux | $(LLVM_DIS) | \
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 262/634 selftests/bpf: Support checks against a regular expression
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cupertino Miranda <[email protected]>
[ Upstream commit f06ae6194f278444201e0b041a00192d794f83b6 ]
Add support for __regex and __regex_unpriv macros to check the test execution output against a regular expression. This is similar to __msg and __msg_unpriv, however those expect do substring matching.
Stable-dep-of: f00bb757ed63 ("selftests/bpf: fix to avoid __msg tag de-duplication by clang")
--- tools/testing/selftests/bpf/progs/bpf_misc.h | 11 +- tools/testing/selftests/bpf/test_loader.c | 115 ++++++++++++++----- 2 files changed, 96 insertions(+), 30 deletions(-)
tools/testing/selftests/bpf/progs/bpf_misc.h +8 -3
@@ -7,9 +7,9 @@* * The test_loader sequentially loads each program in a skeleton. * Programs could be loaded in privileged and unprivileged modes. -* - __success, __failure, __msg imply privileged mode; -* - __success_unpriv, __failure_unpriv, __msg_unpriv imply -* unprivileged mode. +* - __success, __failure, __msg, __regex imply privileged mode; +* - __success_unpriv, __failure_unpriv, __msg_unpriv, __regex_unpriv +* imply unprivileged mode. * If combination of privileged and unprivileged attributes is present * both modes are used. If none are present privileged mode is implied. *
@@ -24,6 +24,9 @@* Multiple __msg attributes could be specified. * __msg_unpriv Same as __msg but for unprivileged mode. * +* __regex Same as __msg, but using a regular expression. +* __regex_unpriv Same as __msg_unpriv but using a regular expression. +* * __success Expect program load success in privileged mode. * __success_unpriv Expect program load success in unprivileged mode. *
@@ -59,10 +62,12 @@* __auxiliary_unpriv Same, but load program in unprivileged mode. */ #define __msg (msg) __attribute__((btf_decl_tag("comment:test_expect_msg=" msg))) +#define __regex (regex) __attribute__((btf_decl_tag("comment:test_expect_regex=" regex)))#define __failure __attribute__((btf_decl_tag("comment:test_expect_failure")))#define __success __attribute__((btf_decl_tag("comment:test_expect_success")))#define __description (desc) __attribute__((btf_decl_tag("comment:test_description=" desc)))#define __msg_unpriv (msg) __attribute__((btf_decl_tag("comment:test_expect_msg_unpriv=" msg))) +#define __regex_unpriv (regex) __attribute__((btf_decl_tag("comment:test_expect_regex_unpriv=" regex)))#define __failure_unpriv __attribute__((btf_decl_tag("comment:test_expect_failure_unpriv")))#define __success_unpriv __attribute__((btf_decl_tag("comment:test_expect_success_unpriv")))#define __log_level (lvl) __attribute__((btf_decl_tag("comment:test_log_level="#lvl)))
tools/testing/selftests/bpf/test_loader.c +88 -27
193 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 263/634 selftests/bpf: no need to track next_match_pos in struct test_loader
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 4ef5d6af493558124b7a6c13cace58b938fe27d4 ]
The call stack for validate_case() function looks as follows:
- test_loader__run_subtests()
- process_subtest()
- run_subtest()
- prepare_case(), which does 'tester->next_match_pos = 0';
- validate_case(), which increments tester->next_match_pos.
Hence, each subtest is run with next_match_pos freshly set to zero. Meaning that there is no need to persist this variable in the struct test_loader, use local variable instead.
Stable-dep-of: f00bb757ed63 ("selftests/bpf: fix to avoid __msg tag de-duplication by clang")
--- tools/testing/selftests/bpf/test_loader.c | 19 ++++++++----------- tools/testing/selftests/bpf/test_progs.h | 1 - 2 files changed, 8 insertions(+), 12 deletions(-)
tools/testing/selftests/bpf/test_loader.c +8 -11
@@ -434,7 +434,6 @@ static void prepare_case(struct test_loader *tester,bpf_program__set_flags (prog, prog_flags | spec->prog_flags); tester->log_buf[0 ] ='\0' ; - tester->next_match_pos =0 ; }static void emit_verifier_log (const char *log_buf,bool force)
@@ -450,25 +449,23 @@ static void validate_case(struct test_loader *tester, struct bpf_program *prog, int load_err) { - int i, j, err; -char *match;regmatch_t reg_match[1 ]; +const char *log = tester->log_buf; +int i, j, err;for (i =0 ; i < subspec->expect_msg_cnt; i++) {struct expect_msg *msg = &subspec->expect_msgs[i]; +const char *match =NULL ;if (msg->substr) { - match =strstr (tester->log_buf + tester->next_match_pos, msg->substr); + match =strstr (log, msg->substr);if (match) - tester->next_match_pos = match - tester->log_buf +strlen (msg->substr); + log +=strlen (msg->substr); }else { - err =regexec (&msg->regex, - tester->log_buf + tester->next_match_pos,1 , reg_match,0 ); + err =regexec (&msg->regex, log,1 , reg_match,0 );if (err ==0 ) { - match = tester->log_buf + tester->next_match_pos + reg_match[0 ].rm_so; - tester->next_match_pos += reg_match[0 ].rm_eo; - }else { - match =NULL ; + match = log + reg_match[0 ].rm_so; + log += reg_match[0 ].rm_eo; } }
tools/testing/selftests/bpf/test_progs.h +0 -1
@@ -438,7 +438,6 @@ typedef int (*pre_execution_cb)(struct bpf_object *obj);struct test_loader {char *log_buf;size_t log_buf_sz; -size_t next_match_pos;pre_execution_cb pre_execution_cb;struct bpf_object *obj;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 264/634 selftests/bpf: extract test_loader->expect_msgs as a data structure
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 64f01e935ddb26f48baec71883c27878ac4231dc ]
Non-functional change: use a separate data structure to represented expected messages in test_loader.
This would allow to use the same functionality for expected set of disassembled instructions in the follow-up commit.
Stable-dep-of: f00bb757ed63 ("selftests/bpf: fix to avoid __msg tag de-duplication by clang")
--- tools/testing/selftests/bpf/test_loader.c | 81 ++++++++++++----------- 1 file changed, 41 insertions(+), 40 deletions(-)
tools/testing/selftests/bpf/test_loader.c +41 -40
@@ -55,11 +55,15 @@ struct expect_msg {regex_t regex; }; +struct expected_msgs { +struct expect_msg *patterns; +size_t cnt; +}; +struct test_subspec {char *name;bool expect_failure; -struct expect_msg *expect_msgs; -size_t expect_msg_cnt; +struct expected_msgs expect_msgs;int retval;bool execute; };
@@ -96,44 +100,45 @@ void test_loader_fini(struct test_loader *tester)free (tester->log_buf); } -static void free_test_spec (struct test_spec *spec) +static void free_msgs (struct expected_msgs *msgs) {int i; +for (i =0 ; i < msgs->cnt; i++) +if (msgs->patterns[i].regex_str) +regfree (&msgs->patterns[i].regex); +free (msgs->patterns); + msgs->patterns =NULL ; + msgs->cnt =0 ; +} + +static void free_test_spec (struct test_spec *spec) +{/* Deallocate expect_msgs arrays. */ -for (i =0 ; i < spec->priv.expect_msg_cnt; i++) -if (spec->priv.expect_msgs[i].regex_str) -regfree (&spec->priv.expect_msgs[i].regex); -for (i =0 ; i < spec->unpriv.expect_msg_cnt; i++) -if (spec->unpriv.expect_msgs[i].regex_str) -regfree (&spec->unpriv.expect_msgs[i].regex); +free_msgs (&spec->priv.expect_msgs); +free_msgs (&spec->unpriv.expect_msgs);free (spec->priv.name);free (spec->unpriv.name); -free (spec->priv.expect_msgs); -free (spec->unpriv.expect_msgs); - spec->priv.name =NULL ; spec->unpriv.name =NULL ; - spec->priv.expect_msgs =NULL ; - spec->unpriv.expect_msgs =NULL ; } -static int push_msg (const char *substr,const char *regex_str,struct test_subspec *subspec) +static int push_msg (const char *substr,const char *regex_str,struct expected_msgs *msgs) {void *tmp;int regcomp_res;char error_msg[100 ];struct expect_msg *msg; - tmp =realloc (subspec->expect_msgs, - (1 + subspec->expect_msg_cnt) *sizeof (struct expect_msg )); + tmp =realloc (msgs->patterns, + (1 + msgs->cnt) *sizeof (struct expect_msg ));if (!tmp) {ASSERT_FAIL ("failed to realloc memory for messages\n" );return -ENOMEM ; } - subspec->expect_msgs = tmp; - msg = &subspec->expect_msgs[subspec->expect_msg_cnt]; + msgs->patterns = tmp; + msg = &msgs->patterns[msgs->cnt];if (substr) { msg->substr = substr;
@@ -150,7 +155,7 @@ static int push_msg(const char *substr, const char *regex_str, struct test_subsp } } - subspec->expect_msg_cnt +=1 ; + msgs->cnt +=1 ;return 0 ; }
@@ -272,25 +277,25 @@ static int parse_test_spec(struct test_loader *tester, spec->mode_mask |=UNPRIV ; }else if (str_has_pfx (s,TEST_TAG_EXPECT_MSG_PFX )) { msg = s +sizeof (TEST_TAG_EXPECT_MSG_PFX ) -1 ; - err =push_msg (msg,NULL , &spec->priv); + err =push_msg (msg,NULL , &spec->priv.expect_msgs);if (err) goto cleanup; spec->mode_mask |=PRIV ; }else if (str_has_pfx (s,TEST_TAG_EXPECT_MSG_PFX_UNPRIV )) { msg = s +sizeof (TEST_TAG_EXPECT_MSG_PFX_UNPRIV ) -1 ; - err =push_msg (msg,NULL , &spec->unpriv); + err =push_msg (msg,NULL , &spec->unpriv.expect_msgs);if (err) goto cleanup; spec->mode_mask |=UNPRIV ; }else if (str_has_pfx (s,TEST_TAG_EXPECT_REGEX_PFX )) { msg = s +sizeof (TEST_TAG_EXPECT_REGEX_PFX ) -1 ; - err =push_msg (NULL , msg, &spec->priv); + err =push_msg (NULL , msg, &spec->priv.expect_msgs);if (err) goto cleanup; spec->mode_mask |=PRIV ; }else if (str_has_pfx (s,TEST_TAG_EXPECT_REGEX_PFX_UNPRIV )) { msg = s +sizeof (TEST_TAG_EXPECT_REGEX_PFX_UNPRIV ) -1 ; - err =push_msg (NULL , msg, &spec->unpriv); + err =push_msg (NULL , msg, &spec->unpriv.expect_msgs);if (err) goto cleanup; spec->mode_mask |=UNPRIV ;
@@ -387,11 +392,12 @@ static int parse_test_spec(struct test_loader *tester, spec->unpriv.execute = spec->priv.execute; } -if (!spec->unpriv.expect_msgs) { -for (i =0 ; i < spec->priv.expect_msg_cnt; i++) { -struct expect_msg *msg = &spec->priv.expect_msgs[i]; +if (spec->unpriv.expect_msgs.cnt ==0 ) { +for (i =0 ; i < spec->priv.expect_msgs.cnt; i++) { +struct expect_msg *msg = &spec->priv.expect_msgs.patterns[i]; - err =push_msg (msg->substr, msg->regex_str, &spec->unpriv); + err =push_msg (msg->substr, msg->regex_str, + &spec->unpriv.expect_msgs);if (err) goto cleanup; }
@@ -443,18 +449,14 @@ static void emit_verifier_log(const char *log_buf, bool force)fprintf (stdout,"VERIFIER LOG:\n=============\n%s=============\n" , log_buf); } -static void validate_case (struct test_loader *tester, -struct test_subspec *subspec, -struct bpf_object *obj, -struct bpf_program *prog, -int load_err) +static void validate_msgs (char *log_buf,struct expected_msgs *msgs) {regmatch_t reg_match[1 ]; -const char *log = tester->log_buf; +const char *log = log_buf;int i, j, err; -for (i =0 ; i < subspec->expect_msg_cnt; i++) { -struct expect_msg *msg = &subspec->expect_msgs[i]; +for (i =0 ; i < msgs->cnt; i++) { +struct expect_msg *msg = &msgs->patterns[i];const char *match =NULL ;if (msg->substr) {
@@ -471,9 +473,9 @@ static void validate_case(struct test_loader *tester,if (!ASSERT_OK_PTR (match,"expect_msg" )) {if (env.verbosity ==VERBOSE_NONE ) -emit_verifier_log (tester->log_buf, true/*force*/ ); +emit_verifier_log (log_buf, true/*force*/ );for (j =0 ; j <= i; j++) { - msg = &subspec->expect_msgs[j]; + msg = &msgs->patterns[j]; fprintf(stderr, "%s %s: '%s'\n", j < i ? "MATCHED " : "EXPECTED", msg->substr ? "SUBSTR" : " REGEX",
@@ -692,9 +694,8 @@ void run_subtest(struct test_loader *tester, goto tobj_cleanup; } } -emit_verifier_log (tester->log_buf, false/*force*/ ); -validate_case (tester, subspec, tobj, tprog, err); +validate_msgs (tester->log_buf, &subspec->expect_msgs);if (should_do_test_run (spec, subspec)) {/* For some reason test_verifier executes programs
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 265/634 selftests/bpf: allow checking xlated programs in verifier_* tests
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 9c9f7339131030949a8ef111080427ff1a8085b5 ]
Add a macro __xlated("...") for use with test_loader tests.
When such annotations are present for the test case:
- bpf_prog_get_info_by_fd() is used to get BPF program after all rewrites are applied by verifier.
- the program is disassembled and patterns specified in __xlated are searched for in the disassembly text.
__xlated matching follows the same mechanics as __msg:
each subsequent pattern is matched from the point where previous pattern ended.
This allows to write tests like below, where the goal is to verify the behavior of one of the of the transformations applied by verifier:
SEC("raw_tp")
__xlated("1: w0 = ")
__xlated("2: r0 = &(void __percpu *)(r0)")
__xlated("3: r0 = *(u32 *)(r0 +0)")
__xlated("4: exit")
__success __naked void simple(void)
{
asm volatile (
"call %[bpf_get_smp_processor_id];"
"exit;"
:
: __imm(bpf_get_smp_processor_id)
: __clobber_all);
}Stable-dep-of: f00bb757ed63 ("selftests/bpf: fix to avoid __msg tag de-duplication by clang")
--- tools/testing/selftests/bpf/progs/bpf_misc.h | 5 ++ tools/testing/selftests/bpf/test_loader.c | 82 +++++++++++++++++++- 2 files changed, 84 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/progs/bpf_misc.h +5 -0
@@ -26,6 +26,9 @@* * __regex Same as __msg, but using a regular expression. * __regex_unpriv Same as __msg_unpriv but using a regular expression. +* __xlated Expect a line in a disassembly log after verifier applies rewrites. +* Multiple __xlated attributes could be specified. +* __xlated_unpriv Same as __xlated but for unprivileged mode. * * __success Expect program load success in privileged mode. * __success_unpriv Expect program load success in unprivileged mode.
@@ -63,11 +66,13 @@*/ #define __msg (msg) __attribute__((btf_decl_tag("comment:test_expect_msg=" msg)))#define __regex (regex) __attribute__((btf_decl_tag("comment:test_expect_regex=" regex))) +#define __xlated (msg) __attribute__((btf_decl_tag("comment:test_expect_xlated=" msg)))#define __failure __attribute__((btf_decl_tag("comment:test_expect_failure")))#define __success __attribute__((btf_decl_tag("comment:test_expect_success")))#define __description (desc) __attribute__((btf_decl_tag("comment:test_description=" desc)))#define __msg_unpriv (msg) __attribute__((btf_decl_tag("comment:test_expect_msg_unpriv=" msg)))#define __regex_unpriv (regex) __attribute__((btf_decl_tag("comment:test_expect_regex_unpriv=" regex))) +#define __xlated_unpriv (msg) __attribute__((btf_decl_tag("comment:test_expect_xlated_unpriv=" msg)))#define __failure_unpriv __attribute__((btf_decl_tag("comment:test_expect_failure_unpriv")))#define __success_unpriv __attribute__((btf_decl_tag("comment:test_expect_success_unpriv")))#define __log_level (lvl) __attribute__((btf_decl_tag("comment:test_log_level="#lvl)))
tools/testing/selftests/bpf/test_loader.c +79 -3
146 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/634 selftests/bpf: __arch_* macro to limit test cases to specific archs
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit ee7fe84468b1732fe65c5af3836437d54ac4c419 ]
Add annotations __arch_x86_64, __arch_arm64, __arch_riscv64 to specify on which architecture the test case should be tested. Several __arch_* annotations could be specified at once. When test case is not run on current arch it is marked as skipped.
For example, the following would be tested only on arm64 and riscv64:
SEC("raw_tp")
__arch_arm64
__arch_riscv64
__xlated("1: *(u64 *)(r10 - 16) = r1")
__xlated("2: call")
__xlated("3: r1 = *(u64 *)(r10 - 16);")
__success
__naked void canary_arm64_riscv64(void)
{
asm volatile (
"r1 = 1;"
"*(u64 *)(r10 - 16) = r1;"
"call %[bpf_get_smp_processor_id];"
"r1 = *(u64 *)(r10 - 16);"
"exit;"
:
: __imm(bpf_get_smp_processor_id)
: __clobber_all);
}On x86 it would be skipped:
#467/2 verifier_nocsr/canary_arm64_riscv64:SKIP
Stable-dep-of: f00bb757ed63 ("selftests/bpf: fix to avoid __msg tag de-duplication by clang")
--- tools/testing/selftests/bpf/progs/bpf_misc.h | 8 ++++ tools/testing/selftests/bpf/test_loader.c | 43 ++++++++++++++++++++ 2 files changed, 51 insertions(+)
tools/testing/selftests/bpf/progs/bpf_misc.h +8 -0
@@ -63,6 +63,10 @@* __auxiliary Annotated program is not a separate test, but used as auxiliary * for some other test cases and should always be loaded. * __auxiliary_unpriv Same, but load program in unprivileged mode. +* +* __arch_* Specify on which architecture the test case should be tested. +* Several __arch_* annotations could be specified at once. +* When test case is not run on current arch it is marked as skipped. */ #define __msg (msg) __attribute__((btf_decl_tag("comment:test_expect_msg=" msg)))#define __regex (regex) __attribute__((btf_decl_tag("comment:test_expect_regex=" regex)))
@@ -82,6 +86,10 @@#define __auxiliary __attribute__((btf_decl_tag("comment:test_auxiliary")))#define __auxiliary_unpriv __attribute__((btf_decl_tag("comment:test_auxiliary_unpriv")))#define __btf_path (path) __attribute__((btf_decl_tag("comment:test_btf_path=" path))) +#define __arch (arch) __attribute__((btf_decl_tag("comment:test_arch=" arch))) +#define __arch_x86_64 __arch("X86_64") +#define __arch_arm64 __arch("ARM64") +#define __arch_riscv64 __arch("RISCV64")/* Convenience macro for use with 'asm volatile' blocks */ #define __naked __attribute__((naked))
tools/testing/selftests/bpf/test_loader.c +43 -0
90 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/634 selftests/bpf: fix to avoid __msg tag de-duplication by clang
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit f00bb757ed630affc951691ddaff206039cbb7ee ]
__msg, __regex and __xlated tags are based on
__attribute__((btf_decl_tag("..."))) annotations.
Clang de-duplicates such annotations, e.g. the following two sequences of tags are identical in final BTF:
/* seq A */ /* seq B */
__tag("foo") __tag("foo")
__tag("bar") __tag("bar")
__tag("foo")Fix this by adding a unique suffix for each tag using __COUNTER__ pre-processor macro. E.g. here is a new definition for __msg:
#define __msg(msg) \
__attribute__((btf_decl_tag("comment:test_expect_msg=" XSTR(__COUNTER__) "=" msg)))Using this definition the "seq A" from example above is translated to BTF as follows:
[..] DECL_TAG 'comment:test_expect_msg=0=foo' type_id=X component_idx=-1
[..] DECL_TAG 'comment:test_expect_msg=1=bar' type_id=X component_idx=-1
[..] DECL_TAG 'comment:test_expect_msg=2=foo' type_id=X component_idx=-1Surprisingly, this bug affects a single existing test:
verifier_spill_fill/old_stack_misc_vs_cur_ctx_ptr, where sequence of identical messages was expected in the log.
--- tools/testing/selftests/bpf/progs/bpf_misc.h | 15 +++--- .../selftests/bpf/progs/verifier_spill_fill.c | 8 ++-- tools/testing/selftests/bpf/test_loader.c | 47 ++++++++++++++----- 3 files changed, 48 insertions(+), 22 deletions(-)
tools/testing/selftests/bpf/progs/bpf_misc.h +9 -6
@@ -2,6 +2,9 @@#ifndef __BPF_MISC_H__#define __BPF_MISC_H__ +#define XSTR (s) STR(s) +#define STR (s) #s +/* This set of attributes controls behavior of the * test_loader.c:test_loader__run_subtests(). *
@@ -68,15 +71,15 @@* Several __arch_* annotations could be specified at once. * When test case is not run on current arch it is marked as skipped. */ -#define __msg (msg) __attribute__((btf_decl_tag("comment:test_expect_msg=" msg))) -#define __regex (regex) __attribute__((btf_decl_tag("comment:test_expect_regex=" regex))) -#define __xlated (msg) __attribute__((btf_decl_tag("comment:test_expect_xlated=" msg))) +#define __msg (msg) __attribute__((btf_decl_tag("comment:test_expect_msg=" XSTR(__COUNTER__) "=" msg))) +#define __regex (regex) __attribute__((btf_decl_tag("comment:test_expect_regex=" XSTR(__COUNTER__) "=" regex))) +#define __xlated (msg) __attribute__((btf_decl_tag("comment:test_expect_xlated=" XSTR(__COUNTER__) "=" msg)))#define __failure __attribute__((btf_decl_tag("comment:test_expect_failure")))#define __success __attribute__((btf_decl_tag("comment:test_expect_success")))#define __description (desc) __attribute__((btf_decl_tag("comment:test_description=" desc))) -#define __msg_unpriv (msg) __attribute__((btf_decl_tag("comment:test_expect_msg_unpriv=" msg))) -#define __regex_unpriv (regex) __attribute__((btf_decl_tag("comment:test_expect_regex_unpriv=" regex))) -#define __xlated_unpriv (msg) __attribute__((btf_decl_tag("comment:test_expect_xlated_unpriv=" msg))) +#define __msg_unpriv (msg) __attribute__((btf_decl_tag("comment:test_expect_msg_unpriv=" XSTR(__COUNTER__) "=" msg))) +#define __regex_unpriv (regex) __attribute__((btf_decl_tag("comment:test_expect_regex_unpriv=" XSTR(__COUNTER__) "=" regex))) +#define __xlated_unpriv (msg) __attribute__((btf_decl_tag("comment:test_expect_xlated_unpriv=" XSTR(__COUNTER__) "=" msg)))#define __failure_unpriv __attribute__((btf_decl_tag("comment:test_expect_failure_unpriv")))#define __success_unpriv __attribute__((btf_decl_tag("comment:test_expect_success_unpriv")))#define __log_level (lvl) __attribute__((btf_decl_tag("comment:test_log_level="#lvl)))
tools/testing/selftests/bpf/progs/verifier_spill_fill.c +4 -4
@@ -1213,10 +1213,10 @@ __success __log_level(2)* - once for path entry - label 2; * - once for path entry - label 1 - label 2. */ -__msg("r1 = *(u64 *)(r10 -8)") -__msg("exit") -__msg("r1 = *(u64 *)(r10 -8)") -__msg("exit") +__msg("8: (79) r1 = *(u64 *)(r10 -8)") +__msg("9: (95) exit") +__msg("from 2 to 7") +__msg("8: safe") __msg("processed 11 insns")__flag (BPF_F_TEST_STATE_FREQ) __naked void old_stack_misc_vs_cur_ctx_ptr(void)
tools/testing/selftests/bpf/test_loader.c +35 -12
79 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 268/634 bpf: correctly handle malformed BPF_CORE_TYPE_ID_LOCAL relos
In reply to Greg Kroah-Hartman6.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 3d2786d65aaa954ebd3fcc033ada433e10da21c4 ]
In case of malformed relocation record of kind BPF_CORE_TYPE_ID_LOCAL referencing a non-existing BTF type, function bpf_core_calc_relo_insn would cause a null pointer deference.
Fix this by adding a proper check upper in call stack, as malformed relocation records could be passed from user space.
Simplest reproducer is a program:
r0 = 0
exitWith a single relocation record:
.insn_off = 0, /* patch first instruction */
.type_id = 100500, /* this type id does not exist */
.access_str_off = 6, /* offset of string "0" */ .kind = BPF_CORE_TYPE_ID_LOCAL,
See the link for original reproducer or next commit for a test case.
--- kernel/bpf/btf.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/bpf/btf.c +8 -0
@@ -8718,6 +8718,7 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,struct bpf_core_cand_list cands = {};struct bpf_core_relo_res targ_res;struct bpf_core_spec *specs; +const struct btf_type *type;int err;/* ~4k of temp memory necessary to convert LLVM spec like "0:1:0:5"
@@ -8727,6 +8728,13 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,if (!specs)return -ENOMEM ; + type =btf_type_by_id (ctx->btf, relo->type_id); +if (!type) { +bpf_log (ctx->log,"relo #%u: bad type id %u\n" , + relo_idx, relo->type_id); +return -EINVAL ; + } +if (need_cands) {struct bpf_cand_cache *cc;int i;
Signature · 1 line
2.43.0