From: "Pafford, Robert J." <pafford.9@buckeyemail.osu.edu>
To: Frank Oltmanns <frank@oltmanns.dev>
Cc: "Michael Turquette" <mturquette@baylibre.com>,
"Stephen Boyd" <sboyd@kernel.org>, "Chen-Yu Tsai" <wens@csie.org>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Samuel Holland" <samuel@sholland.org>,
"Guido Günther" <agx@sigxcpu.org>,
"Purism Kernel Team" <kernel@puri.sm>,
"Ondrej Jirman" <megi@xff.cz>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Jessica Zhang" <quic_jesszhan@quicinc.com>,
"Sam Ravnborg" <sam@ravnborg.org>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-sunxi@lists.linux.dev" <linux-sunxi@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH v4 1/5] clk: sunxi-ng: common: Support minimum and maximum rate
Date: Fri, 14 Jun 2024 23:52:08 +0000 [thread overview]
Message-ID: <DM6PR01MB58047C810DDD5D0AE397CADFF7C22@DM6PR01MB5804.prod.exchangelabs.com> (raw)
In-Reply-To: <20240310-pinephone-pll-fixes-v4-1-46fc80c83637@oltmanns.dev>
> The Allwinner SoC's typically have an upper and lower limit for their
> clocks' rates. Up until now, support for that has been implemented
> separately for each clock type.
>
> Implement that functionality in the sunxi-ng's common part making use of
> the CCF rate liming capabilities, so that it is available for all clock
> types.
>
> Suggested-by: Maxime Ripard <mripard@kernel.org>
> Signed-off-by: Frank Oltmanns <frank@oltmanns.dev>
> Cc: stable@vger.kernel.org
> ---
> drivers/clk/sunxi-ng/ccu_common.c | 19 +++++++++++++++++++
> drivers/clk/sunxi-ng/ccu_common.h | 3 +++
> 2 files changed, 22 insertions(+)
This patch appears to cause a buffer under-read bug due to the call to 'hw_to_ccu_common', which assumes all entries
in the desc->hw_clocks->hws array are contained in ccu_common structs.
However, not all clocks in the array are contained in ccu_common structs. For example, as part
of the "sun20i-d1-ccu" driver, the "pll-video0" clock holds the 'clk_hw' struct inside of a 'clk_fixed_factor' struct,
as it is a fixed factor clock based on the "pll-video0-4x" clock, created with the CLK_FIXED_FACTOR_HWS macro.
This results in undefined behavior as the hw_to_ccu_common returns an invalid pointer referencing memory before the
'clk_fixed_factor' struct.
I have attached kernel warnings from a system based on the "sun8i-t113s.dtsi" device tree, where the memory contains
a non-zero value for the min-rate but a zero value for the max-rate, triggering the "No max_rate, ignoring min_rate"
warning in the 'sunxi_ccu_probe' function.
[ 0.549013] ------------[ cut here ]------------
[ 0.553727] WARNING: CPU: 0 PID: 1 at drivers/clk/sunxi-ng/ccu_common.c:155 sunxi_ccu_probe+0x105/0x164
[ 0.563153] No max_rate, ignoring min_rate of clock 6 - pll-periph0-div3
[ 0.569846] Modules linked in:
[ 0.572913] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.6.32-winglet #7
[ 0.579540] Hardware name: Generic DT based system
[ 0.584350] unwind_backtrace from show_stack+0xb/0xc
[ 0.589445] show_stack from dump_stack_lvl+0x2b/0x34
[ 0.594531] dump_stack_lvl from __warn+0x5d/0x92
[ 0.599275] __warn from warn_slowpath_fmt+0xd7/0x12c
[ 0.604354] warn_slowpath_fmt from sunxi_ccu_probe+0x105/0x164
[ 0.610299] sunxi_ccu_probe from devm_sunxi_ccu_probe+0x3d/0x60
[ 0.616317] devm_sunxi_ccu_probe from sun20i_d1_ccu_probe+0xbf/0xec
[ 0.622681] sun20i_d1_ccu_probe from platform_probe+0x3d/0x78
[ 0.628542] platform_probe from really_probe+0x81/0x1d0
[ 0.633862] really_probe from __driver_probe_device+0x59/0x130
[ 0.639813] __driver_probe_device from driver_probe_device+0x2d/0xc8
[ 0.646283] driver_probe_device from __driver_attach+0x4d/0xf0
[ 0.652216] __driver_attach from bus_for_each_dev+0x49/0x84
[ 0.657888] bus_for_each_dev from bus_add_driver+0x91/0x13c
[ 0.663567] bus_add_driver from driver_register+0x37/0xa4
[ 0.669066] driver_register from do_one_initcall+0x41/0x1c4
[ 0.674740] do_one_initcall from kernel_init_freeable+0x13d/0x180
[ 0.680937] kernel_init_freeable from kernel_init+0x15/0xec
[ 0.686607] kernel_init from ret_from_fork+0x11/0x1c
[ 0.691674] Exception stack(0xc8815fb0 to 0xc8815ff8)
[ 0.696739] 5fa0: 00000000 00000000 00000000 00000000
[ 0.704926] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 0.713111] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 0.719765] ---[ end trace 0000000000000000 ]---
[ 0.724452] ------------[ cut here ]------------
[ 0.729082] WARNING: CPU: 0 PID: 1 at drivers/clk/sunxi-ng/ccu_common.c:155 sunxi_ccu_probe+0x105/0x164
[ 0.738518] No max_rate, ignoring min_rate of clock 9 - pll-video0
[ 0.744730] Modules linked in:
[ 0.747801] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.6.32-winglet #7
[ 0.755911] Hardware name: Generic DT based system
[ 0.760696] unwind_backtrace from show_stack+0xb/0xc
[ 0.765768] show_stack from dump_stack_lvl+0x2b/0x34
[ 0.770859] dump_stack_lvl from __warn+0x5d/0x92
[ 0.775600] __warn from warn_slowpath_fmt+0xd7/0x12c
[ 0.780668] warn_slowpath_fmt from sunxi_ccu_probe+0x105/0x164
[ 0.786620] sunxi_ccu_probe from devm_sunxi_ccu_probe+0x3d/0x60
[ 0.792664] devm_sunxi_ccu_probe from sun20i_d1_ccu_probe+0xbf/0xec
[ 0.799035] sun20i_d1_ccu_probe from platform_probe+0x3d/0x78
[ 0.804901] platform_probe from really_probe+0x81/0x1d0
[ 0.810229] really_probe from __driver_probe_device+0x59/0x130
[ 0.816171] __driver_probe_device from driver_probe_device+0x2d/0xc8
[ 0.822624] driver_probe_device from __driver_attach+0x4d/0xf0
[ 0.828566] __driver_attach from bus_for_each_dev+0x49/0x84
[ 0.834237] bus_for_each_dev from bus_add_driver+0x91/0x13c
[ 0.839925] bus_add_driver from driver_register+0x37/0xa4
[ 0.845441] driver_register from do_one_initcall+0x41/0x1c4
[ 0.851123] do_one_initcall from kernel_init_freeable+0x13d/0x180
[ 0.857335] kernel_init_freeable from kernel_init+0x15/0xec
[ 0.863022] kernel_init from ret_from_fork+0x11/0x1c
[ 0.868096] Exception stack(0xc8815fb0 to 0xc8815ff8)
[ 0.873145] 5fa0: 00000000 00000000 00000000 00000000
[ 0.881332] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 0.889525] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 0.896165] ---[ end trace 0000000000000000 ]---
[ 0.900821] ------------[ cut here ]------------
[ 0.905471] WARNING: CPU: 0 PID: 1 at drivers/clk/sunxi-ng/ccu_common.c:155 sunxi_ccu_probe+0x105/0x164
[ 0.914885] No max_rate, ignoring min_rate of clock 12 - pll-video1
[ 0.921143] Modules linked in:
[ 0.924208] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.6.32-winglet #7
[ 0.932308] Hardware name: Generic DT based system
[ 0.937102] unwind_backtrace from show_stack+0xb/0xc
[ 0.942173] show_stack from dump_stack_lvl+0x2b/0x34
[ 0.947254] dump_stack_lvl from __warn+0x5d/0x92
[ 0.952004] __warn from warn_slowpath_fmt+0xd7/0x12c
[ 0.957081] warn_slowpath_fmt from sunxi_ccu_probe+0x105/0x164
[ 0.963034] sunxi_ccu_probe from devm_sunxi_ccu_probe+0x3d/0x60
[ 0.969052] devm_sunxi_ccu_probe from sun20i_d1_ccu_probe+0xbf/0xec
[ 0.975422] sun20i_d1_ccu_probe from platform_probe+0x3d/0x78
[ 0.981288] platform_probe from really_probe+0x81/0x1d0
[ 0.986607] really_probe from __driver_probe_device+0x59/0x130
[ 0.992540] __driver_probe_device from driver_probe_device+0x2d/0xc8
[ 0.999002] driver_probe_device from __driver_attach+0x4d/0xf0
[ 1.004944] __driver_attach from bus_for_each_dev+0x49/0x84
[ 1.010606] bus_for_each_dev from bus_add_driver+0x91/0x13c
[ 1.016286] bus_add_driver from driver_register+0x37/0xa4
[ 1.021785] driver_register from do_one_initcall+0x41/0x1c4
[ 1.027467] do_one_initcall from kernel_init_freeable+0x13d/0x180
[ 1.033679] kernel_init_freeable from kernel_init+0x15/0xec
[ 1.039356] kernel_init from ret_from_fork+0x11/0x1c
[ 1.044440] Exception stack(0xc8815fb0 to 0xc8815ff8)
[ 1.049496] 5fa0: 00000000 00000000 00000000 00000000
[ 1.057674] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 1.065850] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 1.072471] ---[ end trace 0000000000000000 ]---
[ 1.077106] ------------[ cut here ]------------
[ 1.081734] WARNING: CPU: 0 PID: 1 at drivers/clk/sunxi-ng/ccu_common.c:155 sunxi_ccu_probe+0x105/0x164
[ 1.091165] No max_rate, ignoring min_rate of clock 16 - pll-audio0
[ 1.097441] Modules linked in:
[ 1.100503] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 6.6.32-winglet #7
[ 1.108602] Hardware name: Generic DT based system
[ 1.113404] unwind_backtrace from show_stack+0xb/0xc
[ 1.118474] show_stack from dump_stack_lvl+0x2b/0x34
[ 1.123564] dump_stack_lvl from __warn+0x5d/0x92
[ 1.128288] __warn from warn_slowpath_fmt+0xd7/0x12c
[ 1.133356] warn_slowpath_fmt from sunxi_ccu_probe+0x105/0x164
[ 1.139283] sunxi_ccu_probe from devm_sunxi_ccu_probe+0x3d/0x60
[ 1.145318] devm_sunxi_ccu_probe from sun20i_d1_ccu_probe+0xbf/0xec
[ 1.151680] sun20i_d1_ccu_probe from platform_probe+0x3d/0x78
[ 1.157537] platform_probe from really_probe+0x81/0x1d0
[ 1.162857] really_probe from __driver_probe_device+0x59/0x130
[ 1.168816] __driver_probe_device from driver_probe_device+0x2d/0xc8
[ 1.175278] driver_probe_device from __driver_attach+0x4d/0xf0
[ 1.181219] __driver_attach from bus_for_each_dev+0x49/0x84
[ 1.186908] bus_for_each_dev from bus_add_driver+0x91/0x13c
[ 1.192595] bus_add_driver from driver_register+0x37/0xa4
[ 1.198103] driver_register from do_one_initcall+0x41/0x1c4
[ 1.203803] do_one_initcall from kernel_init_freeable+0x13d/0x180
[ 1.210006] kernel_init_freeable from kernel_init+0x15/0xec
[ 1.215684] kernel_init from ret_from_fork+0x11/0x1c
[ 1.220759] Exception stack(0xc8815fb0 to 0xc8815ff8)
[ 1.225806] 5fa0: 00000000 00000000 00000000 00000000
[ 1.233984] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 1.242169] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 1.248818] ---[ end trace 0000000000000000 ]---
next prev parent reply other threads:[~2024-06-14 23:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-10 13:21 [PATCH v4 0/5] Pinephone video out fixes (flipping between two frames) Frank Oltmanns
2024-03-10 13:21 ` [PATCH v4 1/5] clk: sunxi-ng: common: Support minimum and maximum rate Frank Oltmanns
2024-03-13 18:17 ` Jernej Škrabec
2024-03-15 13:04 ` Maxime Ripard
2024-05-21 13:35 ` Måns Rullgård
2024-05-22 6:33 ` Frank Oltmanns
2024-05-22 18:07 ` Måns Rullgård
2024-05-23 18:58 ` Måns Rullgård
2024-06-12 13:28 ` Linux regression tracking (Thorsten Leemhuis)
2024-06-12 14:42 ` Greg KH
2024-06-14 23:52 ` Pafford, Robert J. [this message]
2024-06-20 15:27 ` Frank Oltmanns
2024-06-26 16:02 ` Pafford, Robert J.
2024-06-26 17:07 ` Frank Oltmanns
2024-06-27 1:22 ` Pafford, Robert J.
2024-06-27 4:46 ` Chen-Yu Tsai
2024-03-10 13:21 ` [PATCH v4 2/5] clk: sunxi-ng: a64: Set minimum and maximum rate for PLL-MIPI Frank Oltmanns
2024-03-13 18:18 ` Jernej Škrabec
2024-03-10 13:21 ` [PATCH v4 3/5] clk: sunxi-ng: nkm: Support constraints on m/n ratio and parent rate Frank Oltmanns
2024-03-10 13:21 ` [PATCH v4 4/5] clk: sunxi-ng: a64: Add constraints on PLL-MIPI's n/m " Frank Oltmanns
2024-03-10 13:21 ` [PATCH v4 5/5] arm64: dts: allwinner: a64: Run GPU at 432 MHz Frank Oltmanns
2024-03-13 18:19 ` Jernej Škrabec
2024-04-03 15:31 ` [PATCH v4 0/5] Pinephone video out fixes (flipping between two frames) Frank Oltmanns
2024-04-08 6:48 ` Stephen Boyd
2024-04-15 21:25 ` Jernej Škrabec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM6PR01MB58047C810DDD5D0AE397CADFF7C22@DM6PR01MB5804.prod.exchangelabs.com \
--to=pafford.9@buckeyemail.osu.edu \
--cc=agx@sigxcpu.org \
--cc=airlied@gmail.com \
--cc=conor+dt@kernel.org \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=frank@oltmanns.dev \
--cc=jernej.skrabec@gmail.com \
--cc=kernel@puri.sm \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=maarten.lankhorst@linux.intel.com \
--cc=megi@xff.cz \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=quic_jesszhan@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=sam@ravnborg.org \
--cc=samuel@sholland.org \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®