0

For some years it worked,but now,maybe due to the recent changes added on the FreeBSD 13 and 14 code,it does not work anymore : I'm talking about the ability to passthru one Nvidia GpU from the host os (FreeBSD 14.0 in this case) to any Linux vm. The same procedure that worked until "yesterday" it does not work anymore (for me).

The developer does not reply to my message anymore. I would like to be sure that is true that it is bugged,as it seems,and not that I'm making some mistake. So,I will explain what I do to enable this functionality. I hope that someone wants to also try or that he tries a different procedure that works. The most important thing is that we will be able to enable the function.

So,time ago the developer gave me 3 scripts to run in sequence. They are the following :

a) setup_git_140.sh

git clone https://github.com/beckhoff/freebsd-src /usr/corvin-src-140 

b) build_branch_140.sh

 #!/bin/sh usage() { cat >&2 << EOF Usage: ${0} <branch> [<build_options>] Checkouts to <branch> and builds it with <build_options> (see build.sh for more information). EOF exit 1 } set -e set -u readonly script_path="$(cd "$(dirname "${0}")" && pwd)" readonly branch="${1?Missing <branch>$(usage)}" shift echo $branch cd /usr/corvin-src-140 git fetch --all --prune git checkout -f "${branch}" ${script_path}/build_140.sh "$@" 

c) build_build_140.sh

 #!/bin/sh usage() { cat >&2 << EOF Usage: ${0} [--no-bhf] [--reboot] [--verbose] [--without- kernel] Builds bhyve EOF exit 1 } build_module() { local _path _path="${1}" # change to module path cd "${_path}" # clean module if test "${clean}" = "true"; then make clean > "${cmd_redirect}" 2>&1 fi # build module make > "${cmd_redirect}" 2>&1 # install module make install > "${cmd_redirect}" } build() { build_module "${src_dir}/include" build_module "${src_dir}/lib/libvmmapi" build_module "${src_dir}/sys/modules/vmm" # build kernel if test "${with_kernel}" = "true"; then cd "${src_dir}" local kern_opts kern_opts="-j$(sysctl -n hw.ncpu)" if test "${with_bhf}" = "true"; then kern_opts="${kern_opts} KERNCONF=BHF" fi if ! test "${clean}" = "true"; then kern_opts="${kern_opts} NO_CLEAN=YES" fi make kernel ${kern_opts} > "${cmd_redirect}" 2>&1 fi build_module "${src_dir}/usr.sbin/bhyve" build_module "${src_dir}/usr.sbin/bhyvectl" build_module "${src_dir}/usr.sbin/bhyveload" if test "${with_reboot}" = "true"; then reboot fi } set -e set -u while test $# -gt 0; do case "${1-}" in --clean) clean="true" shift ;; --reboot) with_reboot="true" shift ;; --src-dir=*) src_dir="${1#*=}" shift ;; --verbose) cmd_redirect="/dev/stdout" shift ;; --without-bhf) with_bhf="false" shift ;; --without-kernel) with_kernel="false" shift ;; *) usage ;; esac done readonly clean="${clean-"false"}" readonly cmd_redirect="${cmd_redirect-"/dev/null"}" readonly src_dir="${src_dir-"/usr/corvin-src-140"}" echo $src_dir readonly with_bhf="${with_bhf-"true"}" readonly with_kernel="${with_kernel-"true"}" readonly with_reboot="${with_reboot-"false"}" build 

Here we go. This is what I do to start the compilation that should produce the working bhyve system files that will give to use the passthru of one nvidia gpu on FreeBSD 14.0 :

a) ./setup_git_140.sh b) ./build_branch_140.sh origin/phab/corvink/14.0/nvidia-wip --without-bhf --verbose 

ok. It compiled the code without giving errors,until a certain point,when it happens what you see below. I want to understand if the code is bugged. Please help me :

/usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1174:21: error: use of undeclared identifier 'ctx' passthru_cfgwrite(ctx, vcpu, pi, offset - 0x88000, size, value); ^ /usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1174:26: error: use of undeclared identifier 'vcpu' passthru_cfgwrite(ctx, vcpu, pi, offset - 0x88000, size, value); ^ /usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1209:20: error: use of undeclared identifier 'ctx' passthru_cfgread(ctx, vcpu, pi, offset - 0x88000, size, (uint32_t *)&val); ^ /usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1209:25: error: use of undeclared identifier 'vcpu' passthru_cfgread(ctx, vcpu, pi, offset - 0x88000, size, (uint32_t *)&val); ^ /usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1302:29: error: use of undeclared identifier 'ctx' if (vm_unmap_pptdev_mmio(ctx, sc- >psc_sel.pc_bus, ^ /usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1309:27: error: use of undeclared identifier 'ctx' if (vm_map_pptdev_mmio(ctx, sc- >psc_sel.pc_bus, ^ /usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1327:29: error: use of undeclared identifier 'ctx' if (vm_unmap_pptdev_mmio(ctx, sc- >psc_sel.pc_bus, ^ /usr/corvin-src-140/usr.sbin/bhyve/pci_passthru.c:1334:27: error: use of undeclared identifier 'ctx' if (vm_map_pptdev_mmio(ctx, sc- >psc_sel.pc_bus, ^ 8 errors generated. *** Error code 1 

The passthru of one nvidia card inside a linux vm WILL NOT work if you don't do what I have explained. The FreeBSD wiki does not talk about the nvidia gpu,but only about network interfaces. If you want to help me,if you have one nvidia card, if you want to pass it through inside a Linux VM,you SHOULD repeat the steps that I have explained. And tell me if you are able to compile the code successfully.

Thanks

2
  • I think you need to update setup_git_140.sh to pull by TAG and not the entire repo/main, and you'd see the mistake. Release Tags. As you can see there is no 14.0.0 tag, which means you need to see if it builds on 13, as that is the last available tag. Unfortunately, it looks like the headers were altered in version 14. I believe the identifiers are defined in the Kernel Header Files. They were either removed or renamed, which is what's causing the error. Commented Feb 23, 2024 at 17:52
  • Can't you just pass -H -A flags to bhyve to hide it from VM, make VM think GPU is bare metal. Commented Sep 21 at 0:27

1 Answer 1

0

Checkout by TAG

To checkout a tag:

  1. First, lets gather all the tags: git fetch --all --tags
  2. After finding the available tags: git checkout tags/<tag> -b <branch>

The TAG and the BRANCH NAME should relatively match.

You only need to either update the Fetch commands, or tell the developer to harvest the tags in the script he gave you, and then print and fetch either the one you select or the most recent.

Second Method

  1. Visit the Tags Page.
  2. As you can see there is no Tag for 14 yet, but you can download the source tarball and extract it to your /usr/corvon/src location when it's ready.

Using the method you were given will work when the source is ready to build. WIP indicates Work In Progress. Treat this as a daily/nightly build that won't always build.

8
  • Sorry I didn't understand if it will work or not. And if it can work,how ? Can you post here the commands that I should Issue ? sorry I'm not experienced with this kind of stuff. Commented Feb 24, 2024 at 9:39
  • I posted the commands above Commented Feb 25, 2024 at 2:01
  • # git clone github.com/beckhoff/freebsd-src /usr/corvin-src ; # cd /usr/corvin-src ; # git fetch --all --tags = NO OUTPUT. Commented Feb 26, 2024 at 10:47
  • maybe this ? ---> pastebin.ubuntu.com/p/WWkxDnnVQB Commented Feb 26, 2024 at 10:51
  • Instead,listing branches you will see what I need : pastebin.ubuntu.com/p/XGZD9xgW4R ; I mean this : "origin/phab/corvink/14.0/nvidia-wip" Commented Feb 26, 2024 at 11:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.