Skip to content

Commit

Permalink
Introduce fboff to disable framebuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
MakiseKurisu committed Feb 28, 2022
1 parent 3ae5fa5 commit 1bb7f7d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ cat /etc/pve/qemu-server/204.conf

### 2.7. `pci_remove` and `pci_rescan`

In the reverse of 2.6, sometimes host will actually hold some memory in PCI device's address space, and prevent that space being handled by vfio-pci driver. One common example is `simplefb` allocating `BOOTFB` in [boot GPU's address space](https://github.com/torvalds/linux/blob/7e57714cd0ad2d5bb90e50b5096a0e671dec1ef3/drivers/firmware/sysfb_simplefb.c#L115) despite setting `video=simplefb:off` in kernel cmdline. A [hack](https://github.com/furkanmustafa/forcefully-remove-bootfb) exists but it is [not guranteed to work for everyone](https://github.com/SRH1605/forcefully-remove-bootfb/pull/1#issuecomment-1054073276). As such one can unbind and rebind the PCI device to free up the entire address space allocated for the device, indirectly getting rid of the offending memory allocation.
In a reverse scenario of 2.6, sometimes host will actually hold some memory in PCI device's address space, and prevent that space being handled by vfio-pci driver and thus the VM. One common example is `simplefb` allocating `BOOTFB` in [boot GPU's address space](https://github.com/torvalds/linux/blob/7e57714cd0ad2d5bb90e50b5096a0e671dec1ef3/drivers/firmware/sysfb_simplefb.c#L115) despite setting `video=simplefb:off` in kernel cmdline. A [hack](https://github.com/furkanmustafa/forcefully-remove-bootfb) exists but it is [not guranteed to work for everyone](https://github.com/SRH1605/forcefully-remove-bootfb/pull/1#issuecomment-1054073276). As such one can unbind and rebind the PCI device to free up the entire address space allocated for the device, indirectly getting rid of the offending memory allocation. However, this won't work on all memory allocation. For memory occupied by `efifb`/`simplefb`, please see below.

The difference between this set of commands and `pci_unbind`/`pci_rebind` is that this set runs before VM is started (need to have all the memory availabe before passthrough), while `pci_unbind`/`pci_rebind` happens after VM is stopped (so we know VGA is no longer in use and can be given back to the host).

Expand All @@ -215,6 +215,20 @@ cat /etc/pve/qemu-server/204.conf
#pci_rescan
```

### 2.8. `fboff`

In addition to the `BOOTFB` issue, many users need to specify `video=efifb:off` or equivalent kernel parameter. However, [not everyone can use that](https://www.reddit.com/r/VFIO/comments/ks7ve3/alternative_to_efifboff/) in their workflow. As such, `fboff` can be used as an alternative to kernel parameter.

```yaml
cat /etc/pve/qemu-server/204.conf

## free memory used by simplefb.0
#fboff simplefb.0
## alternatively..
#fboff efifb.0
#fboff vesafb.0
```

### 3. Legacy features

These are features that are no really longer needed to achieve a good latency in a VM.
Expand Down
9 changes: 9 additions & 0 deletions exec-cmds
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,18 @@ exec_qm_depends() {
qm start "$1"
}

exec_fboff() {
echo "Disabling $1 to prepare to pass GPU to VM$VMID"
echo "$1" > /sys/bus/platform/devices/$1/driver/unbind
}

exec_cmds() {
while read CMD ARG1 ARG2 ARG3 REST; do
case "$CMD" in
"#fboff")
if_action pre-start exec_fboff "$ARG1"
;;

"#pci_remove")
if_action pre-start exec_pci_unbind "$ARG1" "$ARG2" "$ARG3"
;;
Expand Down

0 comments on commit 1bb7f7d

Please sign in to comment.