mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: "Dr. David Alan Gilbert" <dave@treblig.org>, kraxel@redhat.com
Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: a bochs-drm (?) oops on head
Date: Mon, 16 Dec 2024 09:41:52 +0100	[thread overview]
Message-ID: <b2e2a217-dced-472f-9084-9822f7e6803c@suse.de> (raw)
In-Reply-To: <Z18dbfDAiFadsSdg@gallifrey>

[-- Attachment #1: Type: text/plain, Size: 2503 bytes --]

Hi

Am 15.12.24 um 19:18 schrieb Dr. David Alan Gilbert:
> Hey Gerd, Thomas,
>    I've got the following oops that looks bochs-drm related on the current
> HEAD ( 4800575d8c0b2f354ab05ab1c4749e45e213bf73 ) and it's been there
> for at least a few days; this is
[...]
>
> The oops has :
> [   78.463760][    T1]  bochs_pci_driver_init+0x8a/0xc0
>
> in it, hence why I'm blaming that.
> (Other odd observation, the Tuxen flicker heavily during booting!)
>
> [   72.756014][    T1] bochs-drm 0000:00:02.0: vgaarb: deactivate vga console
> [   72.758258][    T1] [drm] Found bochs VGA, ID 0xb0c5.
> [   72.758793][    T1] [drm] Framebuffer size 16384 kB @ 0xfd000000, mmio @ 0xfebf0000.
> [   72.767777][    T1] [drm] Initialized bochs-drm 1.0.0 for 0000:00:02.0 on minor 2
> [   72.839222][    T1] fbcon: bochs-drmdrmfb (fb1) is primary device
> [   72.839311][    T1] fbcon: Remapping primary device, fb1, to tty 1-63
> [   78.402163][    T1] bochs-drm 0000:00:02.0: [drm] fb1: bochs-drmdrmfb frame buffer device
> [   78.459984][    T1] BUG: unable to handle page fault for address: ffff8dd345604004
> [   78.463246][    T1] #PF: supervisor write access in kernel mode
> [   78.463760][    T1] #PF: error_code(0x0002) - not-present page
> [   78.463760][    T1] PGD 72001067 P4D 72001067 PUD 72002067 PMD 7fbe1067 PTE 800ffffffa9fb060
> [   78.463760][    T1] Oops: Oops: 0002 [#1] PREEMPT SMP DEBUG_PAGEALLOC NOPTI
> [   78.463760][    T1] CPU: 2 UID: 0 PID: 1 Comm: swapper/0 Tainted: G        W        N 6.13.0-rc2+ #363 6c653a430ed30aae3dac648429c492a2726da3d7
> [   78.463760][    T1] Tainted: [W]=WARN, [N]=TEST
> [   78.463760][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-3.fc41 04/01/2014
> [   78.463760][    T1] RIP: 0010:devm_drm_dev_init_release+0x4e/0x140
[...]
>
> [   78.463760][    T1] ---[ end Kernel panic - not syncing: Fatal exception ]---
>
>
> The config is a fairly full yes-config ish; see attached.

Thanks for reporting. I've been able to reproduce the problem by setting 
CONFIG_DEBUG_TEST_DRIVER_REMOVE 
<https://elixir.bootlin.com/linux/v6.13-rc2/K/ident/CONFIG_DEBUG_TEST_DRIVER_REMOVE>=y. 
The attached patch fixes the problem for me. Could you please test and 
report back the results.

Best regards
Thomas


>
> Dave
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: 0001-drm-bochs-Do-not-put-DRM-device-in-PCI-remove-callba.patch --]
[-- Type: text/x-patch, Size: 3388 bytes --]

From bebba3b34d5df5aa7c882f080633b43ddb87f4ad Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <tzimmermann@suse.de>
Date: Mon, 16 Dec 2024 09:21:46 +0100
Subject: [PATCH] drm/bochs: Do not put DRM device in PCI remove callback

Removing the bochs PCI device should mark the DRM device as unplugged
without removing it. Hence clear the respective call to drm_dev_put()
from bochs_pci_remove().

Fixes a double unref in devm_drm_dev_init_release(). An example error
message is shown below:

[   32.958338] BUG: KASAN: use-after-free in drm_dev_put.part.0+0x1b/0x90
[   32.958850] Write of size 4 at addr ffff888152134004 by task (udev-worker)/591
[   32.959574] CPU: 3 UID: 0 PID: 591 Comm: (udev-worker) Tainted: G            E      6.13.0-rc2-1-default+ #3417
[   32.960316] Tainted: [E]=UNSIGNED_MODULE
[   32.960637] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-2-gc13ff2cd-prebuilt.qemu.org 04/01/2014
[   32.961429] Call Trace:
[   32.961433]  <TASK>
[   32.961439]  dump_stack_lvl+0x68/0x90
[   32.961452]  print_address_description.constprop.0+0x88/0x330
[   32.961461]  ? preempt_count_sub+0x14/0xc0
[   32.961473]  print_report+0xe2/0x1d0
[   32.961479]  ? srso_alias_return_thunk+0x5/0xfbef5
[   32.963725]  ? __virt_addr_valid+0x143/0x320
[   32.964077]  ? srso_alias_return_thunk+0x5/0xfbef5
[   32.964463]  ? drm_dev_put.part.0+0x1b/0x90
[   32.964817]  kasan_report+0xce/0x1a0
[   32.965123]  ? drm_dev_put.part.0+0x1b/0x90
[   32.965474]  kasan_check_range+0xff/0x1c0
[   32.965806]  drm_dev_put.part.0+0x1b/0x90
[   32.966138]  release_nodes+0x84/0xc0
[   32.966447]  devres_release_all+0xd2/0x110
[   32.966788]  ? __pfx_devres_release_all+0x10/0x10
[   32.967177]  ? preempt_count_sub+0x14/0xc0
[   32.967523]  device_unbind_cleanup+0x16/0xc0
[   32.967886]  really_probe+0x1b7/0x570
[   32.968207]  __driver_probe_device+0xca/0x1b0
[   32.968568]  driver_probe_device+0x4a/0xf0
[   32.968907]  __driver_attach+0x10b/0x290
[   32.969239]  ? __pfx___driver_attach+0x10/0x10
[   32.969598]  bus_for_each_dev+0xc0/0x110
[   32.969923]  ? __pfx_bus_for_each_dev+0x10/0x10
[   32.970291]  ? bus_add_driver+0x17a/0x2b0
[   32.970622]  ? srso_alias_return_thunk+0x5/0xfbef5
[   32.971011]  bus_add_driver+0x19a/0x2b0
[   32.971335]  driver_register+0xd8/0x160
[   32.971671]  ? __pfx_bochs_pci_driver_init+0x10/0x10 [bochs]
[   32.972130]  do_one_initcall+0xba/0x390
[...]

After unplugging the DRM device, clients will close their references.
Closing the final reference will also release the DRM device.

Reported-by: Dr. David Alan Gilbert <dave@treblig.org>
Closes: https://lore.kernel.org/lkml/Z18dbfDAiFadsSdg@gallifrey/
Fixes: 04826f588682 ("drm/bochs: Allocate DRM device in struct bochs_device")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux.dev
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tiny/bochs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index 89a699370a59..c67e1f906785 100644
--- a/drivers/gpu/drm/tiny/bochs.c
+++ b/drivers/gpu/drm/tiny/bochs.c
@@ -757,7 +757,6 @@ static void bochs_pci_remove(struct pci_dev *pdev)
 
 	drm_dev_unplug(dev);
 	drm_atomic_helper_shutdown(dev);
-	drm_dev_put(dev);
 }
 
 static void bochs_pci_shutdown(struct pci_dev *pdev)
-- 
2.47.1


  reply	other threads:[~2024-12-16  8:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-15 18:18 Dr. David Alan Gilbert
2024-12-16  8:41 ` Thomas Zimmermann [this message]
2024-12-16 13:46   ` Dr. David Alan Gilbert
2024-12-16 13:59     ` Thomas Zimmermann
2024-12-16 14:35       ` Dr. David Alan Gilbert
2024-12-16 17:24     ` Thomas Zimmermann
2024-12-16 17:35       ` Dr. David Alan Gilbert
2024-12-16 18:56         ` Dr. David Alan Gilbert
2024-12-16 22:09         ` Dr. David Alan Gilbert
2024-12-17  1:04           ` Dr. David Alan Gilbert
2024-12-17 11:43         ` Thomas Zimmermann
2024-12-18 10:41           ` Simona Vetter

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=b2e2a217-dced-472f-9084-9822f7e6803c@suse.de \
    --to=tzimmermann@suse.de \
    --cc=dave@treblig.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux.dev \
    /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®