Bug 285976 - Kernel panic: domain is null
Summary: Kernel panic: domain is null
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bhyve (show other bugs)
Version: 15.0-CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-09 07:39 UTC by 0x1eef
Modified: 2025-04-09 21:48 UTC (History)
2 users (show)

See Also:


Attachments
Kernel panic (186.62 KB, image/jpeg)
2025-04-09 09:09 UTC, 0x1eef
no flags Details
Be more liberal against iommu attach failures (950 bytes, patch)
2025-04-09 09:50 UTC, Konstantin Belousov
no flags Details | Diff
Kernel panic #2 (238.59 KB, image/jpeg)
2025-04-09 10:39 UTC, 0x1eef
no flags Details
vm_assign_pptdev: only call vm_iommu_map() once (1.01 KB, patch)
2025-04-09 11:21 UTC, Konstantin Belousov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description 0x1eef 2025-04-09 07:39:05 UTC
Hello!

I came across a kernel panic ("domain is NULL") when booting my system recently. The panic occurs when bhyve starts, and I reduced the problem to this commit:
2eeb95ccf39ac5d79326c4482112b6b7dd5fc8b2

When I revert 2eeb95ccf39ac5d79326c4482112b6b7dd5fc8b2 the panic disappears, and I can use the VM as usual.

The VM in question is passing through a nvidia graphics card to a Linux VM in case
it's relevant. I also have a nvidia patch applied, taken from https://github.com/Beckhoff/freebsd-src/commits/phab/corvink/15.0/nvidia-wip in case it's relevant.

If any more information is needed please let me know.

Regards,
Robert
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2025-04-09 08:07:31 UTC
What is the backtrace, and the source file/line with the assert?
Comment 2 0x1eef 2025-04-09 09:09:15 UTC
Created attachment 259405 [details]
Kernel panic

I had some trouble getting dumping the trace to disk. I attached a screenshot instead. Please let me know if I can provide anymore information. Thanks
Comment 3 Konstantin Belousov freebsd_committer freebsd_triage 2025-04-09 09:50:50 UTC
Created attachment 259407 [details]
Be more liberal against iommu attach failures
Comment 4 0x1eef 2025-04-09 10:39:34 UTC
Created attachment 259408 [details]
Kernel panic #2

Thanks for the patch. Applied. New panic.
Comment 5 Konstantin Belousov freebsd_committer freebsd_triage 2025-04-09 11:05:58 UTC
I want to see the panic on FreeBSD.
Comment 6 Konstantin Belousov freebsd_committer freebsd_triage 2025-04-09 11:21:59 UTC
Created attachment 259409 [details]
vm_assign_pptdev: only call vm_iommu_map() once
Comment 7 0x1eef 2025-04-09 11:44:41 UTC
Okay. Here is what I did. 
I rebuilt the kernel. Unless world is needed. Let me know.

You can find the patches here:
https://github.com/0x1eef/freebsd-patches

$ sourcezap sh
$ git remote add freebsd/upstream https://github.com/freebsd/freebsd-src
$ git fetch freebsd/upstream
$ git checkout -t freebsd/upstream/main
$ git rev-parse HEAD
253c83058deb5ff77dc0a3b60bf7c1d10f9ef5e8

$ git apply nvidia.patch
$ git apply konstantin1.patch

# sourcezap install
# cd /usr/src
# rm -rf /usr/obj/*
# make -j12 kernel
# reboot


But my system becomes unusable :) Doesn't even boot the kernel.
I saw you added a new patch. Will try. I will have to continue with the hardenedbsd kernel for the time being. Otherwise I will try to figure something out. Thanks for the support.
Comment 8 0x1eef 2025-04-09 12:08:56 UTC
Hello,
I can confirm your second patch fixes the issue for me.
Comment 9 commit-hook freebsd_committer freebsd_triage 2025-04-09 12:21:08 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=42e4938fdbf8e2b5180e0d6aeb0075c589cf3bca

commit 42e4938fdbf8e2b5180e0d6aeb0075c589cf3bca
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-04-09 11:20:30 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-04-09 12:20:08 +0000

    vm_assign_pptdev: only call vm_iommu_map() once

    for the first assigned pass-through device.

    PR:     285976
    Sponsored by:   The FreeBSD Foundation

 sys/amd64/vmm/vmm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2025-04-09 12:21:10 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f3ce5ec77c8ae051fbd284342057d7f5185c0e4

commit 3f3ce5ec77c8ae051fbd284342057d7f5185c0e4
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-04-09 09:46:57 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-04-09 12:20:08 +0000

    bhyve amd64: allow iommu to fail attaching device to host domain

    If iommu does not want to handle some device, e.g. because the ACPI
    table does not list it as translated, this is not a reason to fail
    creating the host domain.

    PR:     285976
    Sponsored by:   The FreeBSD Foundation

 sys/amd64/vmm/io/iommu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)