Page MenuHomeFreeBSD

linuxkpi: Fix iteration in __sg_alloc_table_from_pages again
ClosedPublic

Authored by ashafer_badland.io on Aug 24 2023, 1:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jul 15, 8:00 AM
Unknown Object (File)
Jun 13 2024, 3:06 PM
Unknown Object (File)
Jun 1 2024, 3:52 PM
Unknown Object (File)
May 25 2024, 2:35 AM
Unknown Object (File)
May 17 2024, 9:00 PM
Unknown Object (File)
May 7 2024, 10:09 PM
Unknown Object (File)
Apr 22 2024, 8:28 AM
Unknown Object (File)
Jan 17 2024, 9:03 PM

Details

Summary

Commit 3f686532c9b4 tried to fix an issue with not properly starting
at the first page in the sg list to prevent a panic. This worked but
with the side effect of incrementing "s" during the final iteration,
causing it to be NULL since the list had ended.

This also causes a panic with drm-5.15, since s is null when we later
pass it to sg_mark_end. This change decouples the iteration sg from
s so that s is never incremented past the final page in the chain.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 53266
Build 50157: arc lint + arc unit

Event Timeline

This is part of a fix for https://github.com/amshafer/nvidia-driver/issues/20

I don't think I noticed this problem with my fix the first time since the sg_mark_end(s) call is only hit in drm 5.15, I'm guessing I tested with 5.10.

bz added inline comments.
sys/compat/linuxkpi/common/include/linux/scatterlist.h
386

Please make this a C-style comment. /* .. */

bz added subscribers: wulf, manu, dumbbell.

@dumbbell @manu @wulf unless someone else will review it, I'll likely commit it the next days so it doesn't get lost.

@ashafer_badland.io whe you suggest in your commit message that we panic later passing a NULL, I assume you only test with a non-debug kernel and never hit the KASSERT after the loop which should catch exactly that?

In D41574#951132, @bz wrote:

@dumbbell @manu @wulf unless someone else will review it, I'll likely commit it the next days so it doesn't get lost.

@ashafer_badland.io whe you suggest in your commit message that we panic later passing a NULL, I assume you only test with a non-debug kernel and never hit the KASSERT after the loop which should catch exactly that?

Sorry, forgot about this review, please do commit it so it's in 14.0

This revision is now accepted and ready to land.Sep 6 2023, 6:57 AM

Off the top of my head I thought I tested with GENERIC but because that KASSERT didn't fire I'm assuming I had GENERIC-NODEBUG installed, which I normally do on half my machines.