Skip to contentSkip to conversation

Fedora >= 5.4 kernels instantly freeze on boot without producing any display output

Bug 206175 Linus Torvalds 5 participants 17 messages Jan 14, 2020 – Mar 11, 2020 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]/

A message that is not in the archive (sent off-list or not yet received): [email protected]/

#2 lore raw

Dave, Alex,
there's an odd bugreport on bugzilla, where Artem is seeing an odd
early-boot failure.

That one almost certainly has nothing to do with you guys, but see the later odd (and apparently unrelated) report about some AMD graphics firmware issue and a black screen.

Linus

Quoted 16 lines · On Tue, Jan 14, 2020 at 1:17 PM <[email protected]> wrote:

https://bugzilla.kernel.org/show_bug.cgi?id=206175

--- Comment #9 from Matt Yates ([email protected]) ---
My BIOS vendor is "Insyde Corp.". There is a TPM module. When I disabled it, it caused my EFI boot entry to disappear, so I couldn't test it.

However, I think we may have two separate problems. I switched back from Fedora to Debian Testing, and the Debian installer upgraded the kernel from 5.3 to 5.4 series prior to the first boot. The 5.4 kernel booted up on first boot.
I could see boot messages scrolling, but the screen went to a black while
trying to load lightdm because I did not have the "firmware-amd-graphics" package installed required for graphics. After installing the amd graphics package, the 5.4 kernel freezes as before (right at the start of the boot process). The 5.3 kernel boots as normal, and graphics work.

Quoted 7 lines

The "firmware-amd-graphics" package (version 20190717-2) was the only thing I changed, so I guess the problem must be some sort of conflict with the amd graphics firmware and the 5.4 kernel.

--
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 8 lines · Linus Torvalds

Dave, Alex,
there's an odd bugreport on bugzilla, where Artem is seeing an odd
early-boot failure.

That one almost certainly has nothing to do with you guys, but see the later odd (and apparently unrelated) report about some AMD graphics firmware issue and a black screen.

Odd. I have a similar picasso based raven laptop and it is working fine with F31 and the latest 5.4.8 kernel. I think the firmware is a red herring as the driver won't load without it so if you don't have it installed, the driver won't be running in the first place. I'll follow up in the bug report and ask him to file a new bug about the amdgpu issue to avoid cluttering up the current report.

Alex

Quoted 24 lines

Linus

Quoted 20 lines · On Tue, Jan 14, 2020 at 1:17 PM <[email protected]> wrote:

https://bugzilla.kernel.org/show_bug.cgi?id=206175

--- Comment #9 from Matt Yates ([email protected]) ---
My BIOS vendor is "Insyde Corp.". There is a TPM module. When I disabled it, it caused my EFI boot entry to disappear, so I couldn't test it.

However, I think we may have two separate problems. I switched back from Fedora to Debian Testing, and the Debian installer upgraded the kernel from 5.3 to 5.4 series prior to the first boot. The 5.4 kernel booted up on first boot.
I could see boot messages scrolling, but the screen went to a black while
trying to load lightdm because I did not have the "firmware-amd-graphics" package installed required for graphics. After installing the amd graphics package, the 5.4 kernel freezes as before (right at the start of the boot process). The 5.3 kernel boots as normal, and graphics work.

The "firmware-amd-graphics" package (version 20190717-2) was the only thing I changed, so I guess the problem must be some sort of conflict with the amd graphics firmware and the 5.4 kernel.

Quoted 7 lines
Quoted 3 lines

--
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]/

A message that is not in the archive (sent off-list or not yet received): CAHk-=wi4GS05j67V0D_cRXRQ=_Jh-NT0OuNpF-JFsDFj7jZK9A@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAHk-=wgB2YMM6kw8W0wq=7efxsRERL14OHMOLU=Nd1OaR+sXvw@mail.gmail.com

#8 lore raw

FYI, Linus' latest rant shows up in bugzilla, but never made it to me, just as the other replies from Artem and Hans. This just shows how broken bugzilla is as a reporting tool. Please be a little more calm, I've always taken reported regressions series and as a first priority, but it really does not help if information is hidden away. Adding Artem to the Cc list and drop bugzilla to make this work a bit better.

Artem, can you test the patch below? This fixes the broken dma_mask handling in platform_device_register_full that could override a perfectly valid mask with 0. If this doesn't work, can you throw in a dump_stack() into the working kernel build to see where platform_device_register_full and setup_pdev_dma_masks get called for your system?

drivers/base/platform.c +0 -13
index 7fa654f1288b..03035661eb6b 100644
@@ -662,19 +662,6 @@ struct platform_device *platform_device_register_full(
 	pdev->dev.of_node_reused = pdevinfo->of_node_reused;
 
 	if (pdevinfo->dma_mask) {
-		/*
-		 * This memory isn't freed when the device is put,
-		 * I don't have a nice idea for that though.  Conceptually
-		 * dma_mask in struct device should not be a pointer.
-		 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
-		 */
-		pdev->dev.dma_mask =
-			kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
-		if (!pdev->dev.dma_mask)
-			goto err;
-
-		kmemleak_ignore(pdev->dev.dma_mask);
-
 		*pdev->dev.dma_mask = pdevinfo->dma_mask;
 		pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
 	}
#9 lore raw

As you seem to have a mfd based usb card reader per bugzilla, can you try the patch form Robin below? This ensures mfd doesn't mess with the dma mask and thus entangling it with the parent. And please try to reply to the actual mail. I found some updates in bugzilla when I checked it after I haven't seen any reply for a while, but that isn't a very efficient way to communicate.

drivers/mfd/mfd-core.c +1 -1
@@ -138,7 +138,7 @@ static int mfd_add_device(struct device *parent, int id,
 
  	pdev->dev.parent = parent;
  	pdev->dev.type = &mfd_dev_type;
-	pdev->dev.dma_mask = parent->dma_mask;
+	pdev->dma_mask = parent->dma_mask ? *parent->dma_mask : 0;
  	pdev->dev.dma_parms = parent->dma_parms;
  	pdev->dev.coherent_dma_mask = parent->coherent_dma_mask;
 
#10 lore raw
Quoted 1 line · Christoph Hellwig

pdev->dma_mask = parent->dma_mask ? *parent->dma_mask : 0;

This patch makes no difference.

The kernel panics with the same call trace which starts with:

RIP: 0010:kmem_cache_alloc_trace

...

? acpi_ds_create_walk_state
acpi_ds_create_walk_state
acpi_ds_call_control_method
acpi_ds_parse_aml
acpi_ps_execute_method
acpi_ns_evaluate
acpi_ut_evaluate_object
...

#11 lore raw
Quoted 6 lines · Artem S. Tashkinov
Quoted 1 line · Christoph Hellwig

pdev->dma_mask = parent->dma_mask ? *parent->dma_mask : 0;

This patch makes no difference.

The kernel panics with the same call trace which starts with:

This looks really strange and not dma mask related, but there must be some odd interactions somewhere.

Can you call gdb on the vmlinux file for the 5.5.8-200.fc31 kernel in the jpg and then do

l *(kmem_cache_alloc_trace+0x7e)

l *(acpi_processor_add+0x3a)

and send the output?

#12 lore raw

And actually one more idea after looking at what slab interactions could exist. platform_device_register_full frees the dma_mask unconditionally, even if it didn't allocated it, which might lead to weird memory corruption if we hit the failure path. So let's try something like this, replacing the earlier patch in that file.

drivers/base/platform.c +0 -14
index b230beb6ccb4..04080a8d94e2 100644
@@ -632,19 +632,6 @@ struct platform_device *platform_device_register_full(
 	pdev->dev.of_node_reused = pdevinfo->of_node_reused;
 
 	if (pdevinfo->dma_mask) {
-		/*
-		 * This memory isn't freed when the device is put,
-		 * I don't have a nice idea for that though.  Conceptually
-		 * dma_mask in struct device should not be a pointer.
-		 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
-		 */
-		pdev->dev.dma_mask =
-			kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
-		if (!pdev->dev.dma_mask)
-			goto err;
-
-		kmemleak_ignore(pdev->dev.dma_mask);
-
 		*pdev->dev.dma_mask = pdevinfo->dma_mask;
 		pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
 	}
@@ -670,7 +657,6 @@ struct platform_device *platform_device_register_full(
 	if (ret) {
 err:
 		ACPI_COMPANION_SET(&pdev->dev, NULL);
-		kfree(pdev->dev.dma_mask);
 		platform_device_put(pdev);
 		return ERR_PTR(ret);
 	}
#13 lore raw
Quoted 32 lines · Christoph Hellwig

And actually one more idea after looking at what slab interactions could exist. platform_device_register_full frees the dma_mask unconditionally, even if it didn't allocated it, which might lead to weird memory corruption if we hit the failure path. So let's try something like this, replacing the earlier patch in that file.

drivers/base/platform.c +0 -13
index b230beb6ccb4..04080a8d94e2 100644
@@ -632,19 +632,6 @@ struct platform_device *platform_device_register_full(
  	pdev->dev.of_node_reused = pdevinfo->of_node_reused;
 
  	if (pdevinfo->dma_mask) {
-		/*
-		 * This memory isn't freed when the device is put,
-		 * I don't have a nice idea for that though.  Conceptually
-		 * dma_mask in struct device should not be a pointer.
-		 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
-		 */
-		pdev->dev.dma_mask =
-			kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
-		if (!pdev->dev.dma_mask)
-			goto err;
-
-		kmemleak_ignore(pdev->dev.dma_mask);
-
  		*pdev->dev.dma_mask = pdevinfo->dma_mask;
  		pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
  	}

drivers/base/platform.c struct platform_device *platform_device_register_full( · line 662

Quoted 7 lines
drivers/base/platform.c +0 -1
@@ -670,7 +657,6 @@ struct platform_device *platform_device_register_full(
  	if (ret) {
  err:
  		ACPI_COMPANION_SET(&pdev->dev, NULL);
-		kfree(pdev->dev.dma_mask);
  		platform_device_put(pdev);
  		return ERR_PTR(ret);
  	}

With this patch the system works (I haven't created an initrd, so it doesn't completely boot and panics on not being able to mount root fs but that's expected).

#14 lore raw
Quoted 38 lines · Artem S. Tashkinov
Quoted 37 lines · Christoph Hellwig

And actually one more idea after looking at what slab interactions could exist.  platform_device_register_full frees the dma_mask unconditionally, even if it didn't allocated it, which might lead to weird memory corruption if we hit the failure path.  So let's try something like this, replacing the earlier patch in that file.

drivers/base/platform.c +0 -13
index b230beb6ccb4..04080a8d94e2 100644
@@ -632,19 +632,6 @@ struct platform_device 
 *platform_device_register_full(
       pdev->dev.of_node_reused = pdevinfo->of_node_reused;
 
       if (pdevinfo->dma_mask) {
-        /*
-         * This memory isn't freed when the device is put,
-         * I don't have a nice idea for that though.  Conceptually
-         * dma_mask in struct device should not be a pointer.
-         * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
-         */
-        pdev->dev.dma_mask =
-            kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
-        if (!pdev->dev.dma_mask)
-            goto err;
-
-        kmemleak_ignore(pdev->dev.dma_mask);
-
           *pdev->dev.dma_mask = pdevinfo->dma_mask;
           pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;

      }

drivers/base/platform.c +0 -0
@@ -670,7 +657,6 @@ struct platform_device 
 *platform_device_register_full(
       if (ret) {

  err:
          ACPI_COMPANION_SET(&pdev->dev, NULL);
-        kfree(pdev->dev.dma_mask);

Quoted 8 lines
Quoted 4 lines

          platform_device_put(pdev);
          return ERR_PTR(ret);
      }

With this patch the system works (I haven't created an initrd, so it doesn't completely boot and panics on not being able to mount root fs but that's expected).

Yup, a few lines earlier in the log you can see the wdat_wdt driver failing in platform_device_add(), which since it called into platform_device_register_full() with pdevinfo.dma_mask = 0, will have unwound into that kfree() of pdev.dma_mask corrupting the heap.

Robin.

#15 lore raw
In reply to Artem S. Tashkinov
Quoted 4 lines · Artem S. Tashkinov

With this patch the system works (I haven't created an initrd, so it doesn't completely boot and panics on not being able to mount root fs but that's expected).

Perfect.

I ended up applying my earlier cleanup patch with just the added removal of the kfree(), which was the actual trigger of the bug.

It's commit e423fb6929d4 ("driver code: clarify and fix platform device DMA mask allocation") in my tree. I've not pushed it out yet (I have a few pending pull requests), but it should be out shortly.

Linus

#16 lore raw
Quoted 4 lines · Linus Torvalds

It's commit e423fb6929d4 ("driver code: clarify and fix platform device DMA mask allocation") in my tree. I've not pushed it out yet (I have a few pending pull requests), but it should be out shortly.

Actually, looking at other emails in my mailbox I see that Christoph send a patch with a sign-off, and there's a reviewed-by too, so since I haven't pushed mine out yet, I'll edit that up and give credit to Christoph properly, and add the reviewed-by.

So it will have a different commit ID, updated message, and be a mix of my patch and Christoph's.

Linus

#17 lore raw
Quoted 3 lines · Linus Torvalds

So it will have a different commit ID, updated message, and be a mix of my patch and Christoph's.

I ended up pushing it out before starting on the pull requests, so it's out there now.

Artem, it would be good to have confirmation that my (modified) tip of tree now works for you. I don't actually doubt it does, but a final confirmation would be appreciated.

Linus

#18 lore raw
Quoted 6 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds

So it will have a different commit ID, updated message, and be a mix of my patch and Christoph's.

Quoted 7 lines

I ended up pushing it out before starting on the pull requests, so it's out there now.

Artem, it would be good to have confirmation that my (modified) tip of tree now works for you. I don't actually doubt it does, but a final confirmation would be appreciated.

Should I test kernel 5.6-rc5 with this patch applied or wait for you to commit it?

#19 lore raw
In reply to Linus Torvalds
Quoted 6 lines · Linus Torvalds
Quoted 4 lines · Artem S. Tashkinov

With this patch the system works (I haven't created an initrd, so it doesn't completely boot and panics on not being able to mount root fs but that's expected).

Quoted 8 lines

Perfect.

I ended up applying my earlier cleanup patch with just the added removal of the kfree(), which was the actual trigger of the bug.

It's commit e423fb6929d4 ("driver code: clarify and fix platform device DMA mask allocation") in my tree. I've not pushed it out yet (I have a few pending pull requests), but it should be out shortly.

I've been able to compile and run e3a36eb6dfaeea8175c05d5915dcf0b939be6dab successfully. I won't claim this patch doesn't break something for other people :-)

Best regards,
Artem

#20 lore raw
Quoted 4 lines · Artem S. Tashkinov

I've been able to compile and run e3a36eb6dfaeea8175c05d5915dcf0b939be6dab successfully. I won't claim this patch doesn't break something for other people :-)

Thanks, that's all I was looking for.

If it breaks something for somebody else, I have a solid plan for that
too: I'll just sit in a corner and cry.

Linus

#21 lore raw
In reply to Christoph Hellwig
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Artem S. Tashkinov
Quoted 1 line · Christoph Hellwig

pdev->dma_mask = parent->dma_mask ? *parent->dma_mask : 0;

This patch makes no difference.

The kernel panics with the same call trace which starts with:

This looks really strange and not dma mask related, but there must be some odd interactions somewhere.

Quoted 9 lines

Can you call gdb on the vmlinux file for the 5.5.8-200.fc31 kernel in the jpg and then do

l *(kmem_cache_alloc_trace+0x7e)

l *(acpi_processor_add+0x3a)

and send the output?

I'm not sure I can call or do anything because the system is dead and I'm looking at the kernel panic message. The console is dead. The root file system is not yet mounted. Initrd can't be loaded either. I have no COM port/console. I have no debugging abilities whatsoever. I can only compile kernels and try running them.

#22 lore raw
Quoted 6 lines · Artem S. Tashkinov

I'm not sure I can call or do anything because the system is dead and I'm looking at the kernel panic message. The console is dead. The root file system is not yet mounted. Initrd can't be loaded either. I have no COM port/console. I have no debugging abilities whatsoever. I can only compile kernels and try running them.

Christoph just wanted you to use the image you booted with - you can do it while using a working and entirely unrealted kernel.

But I think Christoph's second email was right on the money: the platform device code used to (accidentally) always use that special kmalloc()'ed memory, and the "always use kfree() to release" then happened to work.

But with the change, platform devices use that allocations inside the platform device itself, and the kfree() now does bad things and corrupts the kmalloc lists.

So that finally makes sense of why that commit would cause odd problems for you. I'm actually surprised it didn't cause problems for others, but it's an error path, and presumably it normally never triggers.

Linus

Linus