Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>, Kees Cook <kees@kernel.org>,
	Mika Westerberg <westeri@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Saravana Kannan <saravanak@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andy Shevchenko <andy@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Srinivas Kandagatla <srini@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Alexey Klimov <alexey.klimov@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v4 03/10] gpiolib: implement low-level, shared GPIO support
Date: Wed, 11 Mar 2026 18:38:16 +0000	[thread overview]
Message-ID: <921ba8ce-b18e-4a99-966d-c763d22081e2@nvidia.com> (raw)
In-Reply-To: <20251112-gpio-shared-v4-3-b51f97b1abd8@linaro.org>

Hi Bartosz,

On 12/11/2025 13:55, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> This module scans the device tree (for now only OF nodes are supported
> but care is taken to make other fwnode implementations easy to
> integrate) and determines which GPIO lines are shared by multiple users.
> It stores that information in memory. When the GPIO chip exposing shared
> lines is registered, the shared GPIO descriptors it exposes are marked
> as shared and virtual "proxy" devices that mediate access to the shared
> lines are created. When a consumer of a shared GPIO looks it up, its
> fwnode lookup is redirected to a just-in-time machine lookup that points
> to this proxy device.
> 
> This code can be compiled out on platforms which don't use shared GPIOs.
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


I have observed a crash on one of our boards with Linux v6.19 and I was
able to reproduce the same crash on a recent -next. The crash log I see
is ...

  Unable to handle kernel paging request at virtual address f0f21322a6ad56c5
  Mem abort info:
    ESR = 0x0000000096000004
    EC = 0x25: DABT (current EL), IL = 32 bits
    SET = 0, FnV = 0
    EA = 0, S1PTW = 0
    FSC = 0x04: level 0 translation fault
  Data abort info:
    ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
    CM = 0, WnR = 0, TnD = 0, TagAccess = 0
    GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
  [f0f21322a6ad56c5] address between user and kernel address ranges
  Internal error: Oops: 0000000096000004 [#1]  SMP
  Modules linked in:
  CPU: 9 UID: 0 PID: 95 Comm: kworker/u51:4 Not tainted 7.0.0-rc3-next-20260309-00004-g34a79c0d58ea-dirty #13 PREEMPT
  Hardware name: NVIDIA NVIDIA Jetson AGX Orin Developer Kit/Jetson, BIOS buildbrain-gcid-42974706 11/20/2025
  Workqueue: events_unbound deferred_probe_work_func
  pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  pc : __srcu_read_lock+0x18/0x84
  lr : gpiod_request_commit+0x30/0x174
  sp : ffff8000843fb8d0
  x29: ffff8000843fb8d0 x28: ffff800081e12000 x27: 0000000000000200
  x26: 00000000000000b9 x25: ffff000080ad92d8 x24: ffff000085cdd940
  x23: ffff800081e12cc0 x22: f0f21322a6ad56c5 x21: ffff800082df0528
  x20: f0f21322a6ad5295 x19: f0f21322a6ad56c5 x18: 00000000ffffffff
  x17: ffff000080c04d80 x16: 1fffe000101809a1 x15: ffff8000843fb530
  x14: ffff000080b17192 x13: ffff000080b1718e x12: ffff0007a1e468b8
  x11: ffff80008199ccf0 x10: 0000000000000000 x9 : 0000000000000000
  x8 : 1fffe0001014ec41 x7 : 0000000000000fff x6 : 0000000000000fff
  x5 : ffff800082df0538 x4 : ffff000081011410 x3 : ffff0000825b82b0
  x2 : ffff0000816daf40 x1 : ffff800081e12cc0 x0 : f0f21322a6ad56c5
  Call trace:
   __srcu_read_lock+0x18/0x84 (P)
   gpiod_request_commit+0x30/0x174
   gpio_device_setup_shared+0x144/0x254
   gpiochip_add_data_with_key+0xc38/0xeec
   devm_gpiochip_add_data_with_key+0x30/0x7c
   tegra186_gpio_probe+0x5cc/0x844
   platform_probe+0x5c/0x98
   really_probe+0xbc/0x2a8
   __driver_probe_device+0x78/0x12c
   driver_probe_device+0x3c/0x15c
   __device_attach_driver+0xb8/0x134
   bus_for_each_drv+0x84/0xe0
   __device_attach+0x9c/0x188
   device_initial_probe+0x50/0x54
   bus_probe_device+0x38/0xa4
   deferred_probe_work_func+0x88/0xc0
   process_one_work+0x154/0x294
   worker_thread+0x184/0x304
   kthread+0x118/0x124
   ret_from_fork+0x10/0x20
  Code: d5384102 910003fd a90153f3 aa0003f3 (f9400014)
  ---[ end trace 0000000000000000 ]---


On Tegra234, the main gpio controller has a total of 164 GPIOs (see
the tegra234_main_ports in drivers/gpio/gpio-tegra186.c). The GPIOs
are assigned a index by the kernel from 0-163, but these GPIOs are
not contiguous with respect to the device-tree specifier.

For example, in device-tree, if I have a shared-gpio with the
following specifier ...

  gpios = <&gpio TEGRA234_MAIN_GPIO(AF, 1) GPIO_ACTIVE_LOW>;

The macro TEGRA234_MAIN_GPIO(AF, 1) evaluates to (23 * 8) + 1 = 185.
This is greater than 164 and this is causing the above crash because
'entry->offset' in gpio_device_setup_shared() is greater than
'gdev->ngpio' and this causes us to access invalid memory.

This is what I have been able to determine so far and wanted to get
your inputs.

Thanks
Jon

-- 
nvpublic


  parent reply	other threads:[~2026-03-11 18:38 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 13:55 [PATCH v4 00/10] gpio: improve support for shared GPIOs Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 01/10] string: provide strends() Bartosz Golaszewski
2025-11-17 20:33   ` Kees Cook
2025-11-18  9:47     ` Bartosz Golaszewski
2025-11-18 10:13       ` Andy Shevchenko
2025-11-12 13:55 ` [PATCH v4 02/10] gpiolib: define GPIOD_FLAG_SHARED Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 03/10] gpiolib: implement low-level, shared GPIO support Bartosz Golaszewski
2025-11-26 15:34   ` Cosmin Tanislav
2025-11-26 15:47     ` Bartosz Golaszewski
2026-03-11 18:38   ` Jon Hunter [this message]
2026-03-11 20:14     ` Andy Shevchenko
2026-03-12  7:28       ` Jon Hunter
2026-03-12  7:49         ` Chen-Yu Tsai
2026-03-12  8:41           ` Jon Hunter
2026-03-12  9:28             ` Andy Shevchenko
2026-03-13 14:18           ` Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 04/10] gpio: shared-proxy: implement the shared GPIO proxy driver Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 05/10] gpiolib: support shared GPIOs in core subsystem code Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 06/10] gpio: provide gpiod_is_shared() Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 07/10] arm64: select HAVE_SHARED_GPIOS for ARCH_QCOM Bartosz Golaszewski
2025-11-13  8:51   ` Arnd Bergmann
2025-11-14 19:40   ` Bjorn Andersson
2025-11-18 14:06   ` Mark Brown
2025-11-18 14:13     ` Bartosz Golaszewski
2025-11-18 14:20       ` Mark Brown
2025-11-18 14:27         ` Bartosz Golaszewski
2025-11-18 19:46           ` Mark Brown
2025-11-26 14:24   ` Jon Hunter
2025-11-26 14:28     ` Bartosz Golaszewski
2025-11-26 14:51       ` Jon Hunter
2025-11-26 14:54         ` Bartosz Golaszewski
2025-11-26 14:55           ` Jon Hunter
2025-11-26 15:05             ` Bartosz Golaszewski
2025-11-26 15:29           ` Jon Hunter
2025-11-26 15:33             ` Bartosz Golaszewski
2025-11-26 15:47               ` Jon Hunter
2025-11-26 16:00                 ` Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 08/10] ASoC: wsa881x: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE flag from GPIO lookup Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 09/10] ASoC: wsa883x: " Bartosz Golaszewski
2025-11-12 13:55 ` [PATCH v4 10/10] regulator: make the subsystem aware of shared GPIOs Bartosz Golaszewski
2025-11-17  9:20 ` (subset) [PATCH v4 00/10] gpio: improve support for " Bartosz Golaszewski
2025-11-18 11:15 ` Geert Uytterhoeven
2025-11-18 11:55   ` Bartosz Golaszewski
2025-11-18 12:55     ` Geert Uytterhoeven
2025-11-18 13:21       ` Bartosz Golaszewski
2025-11-18 23:23   ` Linus Walleij
2025-11-19  8:01     ` Andy Shevchenko
2025-11-19  8:33     ` Geert Uytterhoeven
2025-11-19 14:29       ` Linus Walleij
2025-11-20 10:39 ` (subset) " Mark Brown
2025-11-20 13:36 ` Mark Brown
2025-11-21  0:27 ` Val Packett
2025-11-21  9:03   ` Bartosz Golaszewski
2025-11-21 10:20     ` Krzysztof Kozlowski
2025-11-26 16:27 ` Dmitry Baryshkov
2025-11-26 16:49   ` Bartosz Golaszewski
2026-01-07 11:47   ` Manivannan Sadhasivam
2026-01-07 12:12     ` Dmitry Baryshkov
2026-01-07 12:23       ` Manivannan Sadhasivam
2026-01-08 14:46 ` Michael Walle
2026-01-08 15:50   ` Bartosz Golaszewski
2026-01-09 14:41     ` Michael Walle
2026-01-09 14:50       ` Bartosz Golaszewski
2026-01-09 15:08         ` Michael Walle

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=921ba8ce-b18e-4a99-966d-c763d22081e2@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexey.klimov@linaro.org \
    --cc=andersson@kernel.org \
    --cc=andy@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kees@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=saravanak@google.com \
    --cc=srini@kernel.org \
    --cc=tiwai@suse.com \
    --cc=westeri@kernel.org \
    --cc=will@kernel.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