Skip to content

Instantly share code, notes, and snippets.

@PatrickLang
Last active September 24, 2024 07:04
Show Gist options
  • Save PatrickLang/efb4c2eca310ee5c36a77fbd788e3362 to your computer and use it in GitHub Desktop.
Save PatrickLang/efb4c2eca310ee5c36a77fbd788e3362 to your computer and use it in GitHub Desktop.
Testing drm-hyperv driver in Fedora

Fedora 35

Both the issues mentioned below are solved! My PR to switch to hyperv_drm was accepted, and the kernel fix needed to boot the liveCD are in.

You can boot this as a generation 2 (UEFI) VM with secure boot enabled, using the Microsoft UEFI Certificate Authority setting. Resolution switching works in GNOME under Wayland, even when booted from the live media.

Fedora 34

This is a brief experiment I did to compare these two setups in a Hyper-V VM running Fedora 34

  • DRM-hyperv kernel driver from Linux-next (sort of an in-progress 5.14), using Wayland compositor in Gnome 40
  • hyperv_fb kernel driver in Linux 5.12.9, using X11 in Gnome 40

Subjectively, the DRM-hyperv + Wayland setup felt a lot smoother and more responsive. glxgears performance was similar in terms of total FPS rendered, but it looks smoother with the new framebuffer driver.

The steps to install the kernel were pretty typical, but covered here: https://docs.fedoraproject.org/en-US/quick-docs/kernel/build-custom-kernel/

Fedora rawhide (35)

Fedora rawhide currently has kernel 5.14-rc1 running. There are still a few issues that need to be worked out.

Need updated kernel settings

CONFIG_DRM_HYPERV is not set, so the new graphics driver is not available. It does at least boot in BIOS / generation 1 VMs.

I opened a pull request https://src.fedoraproject.org/rpms/kernel/pull-request/49#commit_list https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1273

UEFI live ISO boot fails

The current nightly Workstation-live-iso isn't booting in UEFI, there is some issue finding the root FS. Surprisingly the ISO is ejected from the virtual SCSI DVD after this failure happens. Adding rdshell to the grub command line shows some more details but I would need to dig a bit deeper to get more logs.

Need to read https://docs.fedoraproject.org/en-US/quick-docs/debug-dracut-problems/ and file a bug

Filed https://bugzilla.redhat.com/show_bug.cgi?id=1984688

Fedora 34 works fine. /proc/cmdline is BOOT_IMAGE=/images/pxeboot/vmlinuz root=live:CDLABEL=Fedora-WS-Live-34-1-2 rd.live.image (maybe with rd.shell rd.debug log_buf_len=1M but not default)

It seems like /dev/sr0 is processed twice by udev, and the second one is setting a different link to the device that's based on the SCSI ID instead of media's labels. When that happens, it ejects /dev/sr0 which of course is bad for a LiveCD

@PatrickLang
Copy link
Author

Rawhide boot failure - still need to debug
rawhide_uefi_boot_failure

@erenes
Copy link

erenes commented Sep 7, 2021

Thanks for your patches! It now works out of the box on Silverblue 35 (while 34 was still using fb)

@Mr-iX
Copy link

Mr-iX commented Feb 22, 2022

I installed Fedora 35 in HyperV as Gen2 VM, but I'm getting the following errors. @PatrickLang Do you have an idea what's the issue?

Feb 22 13:35:12 fedora gnome-shell[1475]: Added device '/dev/dri/card0' (hyperv_drm) using atomic mode setting.
Feb 22 13:35:12 fedora gnome-shell[1475]: MESA-LOADER: failed to open hyperv_drm: /usr/lib64/dri/hyperv_drm_dri.so: Kann die Shared-Object-Datei nicht öffnen: Datei oder Verzeichnis nicht gefunden (search paths /usr/lib64/dri, suffix _dri)
Feb 22 13:35:12 fedora gnome-shell[1475]: failed to load driver: hyperv_drm
Feb 22 13:35:12 fedora gnome-shell[1475]: Disabling DMA buffer screen sharing for driver 'hyperv_drm'.

@virgiliofornazin
Copy link

what you did to make hyperv_drm works? I can't manage it, and there's no documentation on the internet itself

@PatrickLang
Copy link
Author

@virgiliofornazin what Windows version are you using, and what distro are running in the VM?

This needs to be compiled into the kernel. I have tested it recently on openSUSE and Fedora, but not all distros.

This should be documented at https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/feature-descriptions-for-linux-and-freebsd-virtual-machines-on-hyper-v - maybe I can get corrections added

@virgiliofornazin
Copy link

virgiliofornazin commented Jan 26, 2023

I'm using Windows 11 22H2 Enterprise Hyper-V, the distro is the default Ubuntu 22.04 LTS ISO (with all updates), that has hyperv_drm modules built, as you can see below:

virgiliofornazin@i9ubuntuwks /lib/modules
 % find * | grep hyperv | grep drm
5.15.0-57-generic/kernel/drivers/gpu/drm/hyperv
5.15.0-57-generic/kernel/drivers/gpu/drm/hyperv/hyperv_drm.ko
5.15.0-57-lowlatency/kernel/drivers/gpu/drm/hyperv
5.15.0-57-lowlatency/kernel/drivers/gpu/drm/hyperv/hyperv_drm.ko
5.15.0-58-generic/kernel/drivers/gpu/drm/hyperv
5.15.0-58-generic/kernel/drivers/gpu/drm/hyperv/hyperv_drm.ko
5.15.0-58-lowlatency/kernel/drivers/gpu/drm/hyperv
5.15.0-58-lowlatency/kernel/drivers/gpu/drm/hyperv/hyperv_drm.ko

On the page link you sent for features, that are no instructions on how to enable hyperv_drm driver, only this info as you can see below:

Feature | Description
Hyper-V-specific video device | This feature provides high-performance graphics and superior resolution for virtual machines. This device does not provide Enhanced Session Mode or RemoteFX capabilities.

My /etc/default/grub has the following contents:

virgiliofornazin@i9ubuntuwks /lib/modules
 % cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

If I try to change the line to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_drm:1920x1080"

I can't get only 1024x768 resolution.

Boot log with hyperv_drm

Jan 26 12:18:23 i9ubuntuwks kernel: [    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_drm:1920x1080 vt.handoff=7
Jan 26 12:18:23 i9ubuntuwks kernel: [    0.000000] clocksource: hyperv_clocksource_tsc_page: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
Jan 26 12:18:23 i9ubuntuwks kernel: [    0.091978] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_drm:1920x1080 vt.handoff=7
Jan 26 12:18:23 i9ubuntuwks kernel: [    0.264722] clocksource: Switched to clocksource hyperv_clocksource_tsc_page
Jan 26 12:18:23 i9ubuntuwks kernel: [    0.738205] hv_vmbus: registering driver hyperv_keyboard
Jan 26 12:18:23 i9ubuntuwks kernel: [    1.854796] hv_vmbus: registering driver hyperv_fb
Jan 26 12:18:23 i9ubuntuwks kernel: [    1.855399] hyperv_fb: Synthvid Version major 3, minor 5
Jan 26 12:18:23 i9ubuntuwks kernel: [    1.855502] hyperv_fb: Screen resolution: 1024x768, Color depth: 32, Frame buffer size: 8388608
Jan 26 12:18:23 i9ubuntuwks kernel: [    1.957971] hv_vmbus: registering driver hyperv_drm
Jan 26 12:18:35 i9ubuntuwks /usr/libexec/gdm-x-session[3212]: Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_drm:1920x1080 vt.handoff=7
Jan 26 12:18:35 i9ubuntuwks /usr/libexec/gdm-x-session[3212]: (II) FBDEV(0): hardware: hyperv_fb (video memory: 3072kB)
Jan 26 12:18:41 i9ubuntuwks /usr/libexec/gdm-x-session[4091]: Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_drm:1920x1080 vt.handoff=7
Jan 26 12:18:41 i9ubuntuwks /usr/libexec/gdm-x-session[4091]: (II) FBDEV(0): hardware: hyperv_fb (video memory: 3072kB)

...

Jan 26 12:18:36 i9ubuntuwks gnome-session[3313]: gnome-session-check-accelerated: GL Helper exited with code 512
Jan 26 12:18:36 i9ubuntuwks gnome-session[3394]: libEGL warning: DRI2: failed to authenticate
Jan 26 12:18:36 i9ubuntuwks gnome-session[3313]: gnome-session-check-accelerated: GLES Helper exited with code 512
Jan 26 12:18:36 i9ubuntuwks gnome-session[3304]: gnome-session-binary[3304]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:18:36 i9ubuntuwks gnome-session[3304]: gnome-session-binary[3304]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:18:36 i9ubuntuwks gnome-session-binary[3304]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:18:36 i9ubuntuwks gnome-session-binary[3304]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:18:37 i9ubuntuwks gnome-session-binary[3304]: Entering running state
Jan 26 12:18:42 i9ubuntuwks gnome-session[4242]: gnome-session-check-accelerated: GL Helper exited with code 512
Jan 26 12:18:42 i9ubuntuwks gnome-session[4304]: libEGL warning: DRI2: failed to authenticate
Jan 26 12:18:42 i9ubuntuwks gnome-session[4242]: gnome-session-check-accelerated: GLES Helper exited with code 512
Jan 26 12:18:43 i9ubuntuwks gnome-session-binary[4357]: Entering running state
Jan 26 12:18:43 i9ubuntuwks gnome-session[4357]: gnome-session-binary[4357]: GnomeDesktop-WARNING: Could not create transient scope for PID 4535: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4535 does not exist.
Jan 26 12:18:43 i9ubuntuwks gnome-session-binary[4357]: GnomeDesktop-WARNING: Could not create transient scope for PID 4535: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4535 does not exist.
Jan 26 12:18:43 i9ubuntuwks gnome-session-binary[4357]: GnomeDesktop-WARNING: Could not create transient scope for PID 4594: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4594 does not exist.
Jan 26 12:18:43 i9ubuntuwks gnome-session[4357]: gnome-session-binary[4357]: GnomeDesktop-WARNING: Could not create transient scope for PID 4594: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4594 does not exist.
Jan 26 12:18:43 i9ubuntuwks gnome-session-binary[4357]: GnomeDesktop-WARNING: Could not create transient scope for PID 4604: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4604 does not exist.
Jan 26 12:18:43 i9ubuntuwks gnome-session[4357]: gnome-session-binary[4357]: GnomeDesktop-WARNING: Could not create transient scope for PID 4604: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4604 does not exist.
Jan 26 12:18:44 i9ubuntuwks gnome-session[3304]: gnome-session-binary[3304]: GLib-CRITICAL: g_hash_table_foreach_remove_or_steal: assertion 'version == hash_table->version' failed
Jan 26 12:18:44 i9ubuntuwks gnome-session-binary[3304]: GLib-CRITICAL: g_hash_table_foreach_remove_or_steal: assertion 'version == hash_table->version' failed

Boot log with hyperv_fb

Jan 26 12:21:50 i9ubuntuwks kernel: [    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_fb:1920x1080 vt.handoff=7
Jan 26 12:21:50 i9ubuntuwks kernel: [    0.000000] clocksource: hyperv_clocksource_tsc_page: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
Jan 26 12:21:50 i9ubuntuwks kernel: [    0.098532] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_fb:1920x1080 vt.handoff=7
Jan 26 12:21:50 i9ubuntuwks kernel: [    0.274120] clocksource: Switched to clocksource hyperv_clocksource_tsc_page
Jan 26 12:21:50 i9ubuntuwks kernel: [    0.756772] hv_vmbus: registering driver hyperv_keyboard
Jan 26 12:21:50 i9ubuntuwks kernel: [    1.998999] hv_vmbus: registering driver hyperv_fb
Jan 26 12:21:50 i9ubuntuwks kernel: [    1.999648] hyperv_fb: Synthvid Version major 3, minor 5
Jan 26 12:21:50 i9ubuntuwks kernel: [    1.999715] hyperv_fb: Screen resolution: 1920x1080, Color depth: 32, Frame buffer size: 8388608
Jan 26 12:21:50 i9ubuntuwks kernel: [    2.113221] hv_vmbus: registering driver hyperv_drm
Jan 26 12:22:01 i9ubuntuwks /usr/libexec/gdm-x-session[3221]: Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_fb:1920x1080 vt.handoff=7
Jan 26 12:22:02 i9ubuntuwks /usr/libexec/gdm-x-session[3221]: (II) FBDEV(0): hardware: hyperv_fb (video memory: 8100kB)
Jan 26 12:22:09 i9ubuntuwks /usr/libexec/gdm-x-session[4125]: Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-58-lowlatency root=UUID=ef900552-2bab-46e5-8940-196f262a3cf9 ro quiet splash video=hyperv_fb:1920x1080 vt.handoff=7
Jan 26 12:22:09 i9ubuntuwks /usr/libexec/gdm-x-session[4125]: (II) FBDEV(0): hardware: hyperv_fb (video memory: 8100kB)

...

Jan 26 12:22:02 i9ubuntuwks gnome-session[3394]: gnome-session-check-accelerated: GL Helper exited with code 512
Jan 26 12:22:02 i9ubuntuwks gnome-session[3501]: libEGL warning: DRI2: failed to authenticate
Jan 26 12:22:02 i9ubuntuwks gnome-session[3394]: gnome-session-check-accelerated: GLES Helper exited with code 512
Jan 26 12:22:02 i9ubuntuwks gnome-session[3329]: gnome-session-binary[3329]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:22:02 i9ubuntuwks gnome-session[3329]: gnome-session-binary[3329]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:22:02 i9ubuntuwks gnome-session-binary[3329]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:22:02 i9ubuntuwks gnome-session-binary[3329]: GLib-GIO-CRITICAL: g_bus_get_sync: assertion 'error == NULL || *error == NULL' failed
Jan 26 12:22:04 i9ubuntuwks gnome-session-binary[3329]: Entering running state
Jan 26 12:22:10 i9ubuntuwks gnome-session[4328]: gnome-session-check-accelerated: GL Helper exited with code 512
Jan 26 12:22:10 i9ubuntuwks gnome-session[4389]: libEGL warning: DRI2: failed to authenticate
Jan 26 12:22:10 i9ubuntuwks gnome-session[4328]: gnome-session-check-accelerated: GLES Helper exited with code 512
Jan 26 12:22:11 i9ubuntuwks gnome-session-binary[4444]: Entering running state
Jan 26 12:22:11 i9ubuntuwks gnome-session[4444]: gnome-session-binary[4444]: GnomeDesktop-WARNING: Could not create transient scope for PID 4677: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4677 does not exist.
Jan 26 12:22:11 i9ubuntuwks gnome-session[4444]: gnome-session-binary[4444]: GnomeDesktop-WARNING: Could not create transient scope for PID 4687: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4687 does not exist.
Jan 26 12:22:11 i9ubuntuwks gnome-session-binary[4444]: GnomeDesktop-WARNING: Could not create transient scope for PID 4677: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4677 does not exist.
Jan 26 12:22:11 i9ubuntuwks gnome-session-binary[4444]: GnomeDesktop-WARNING: Could not create transient scope for PID 4687: GDBus.Error:org.freedesktop.DBus.Error.UnixProcessIdUnknown: Process with ID 4687 does not exist.
Jan 26 12:22:12 i9ubuntuwks gnome-session[3329]: gnome-session-binary[3329]: GLib-CRITICAL: g_hash_table_foreach_remove_or_steal: assertion 'version == hash_table->version' failed
Jan 26 12:22:12 i9ubuntuwks gnome-session-binary[3329]: GLib-CRITICAL: g_hash_table_foreach_remove_or_steal: assertion 'version == hash_table->version' failed

@PatrickLang
Copy link
Author

@virgiliofornazin yeah you're right about Ubuntu 22.04.

I just installed it, ran an apt upgrade and now I'm using kernel 5.15.0-58-generic. I had to set the resolution with Set-VMVideo -HorizontalResolution:1920 -VerticalResolution:1080 -ResolutionType single from the host, and that worked but I can't change the resolution from inside the VM. dmesg does show that it loaded hyperv_fb instead of hyperv_drm.

Both CONFIG_DRM_HYPERV and CONFIG_FB_HYPERV are set to m. I guess the DRM one is not taking precedence for some reason.

@JaroslavMitrovic
Copy link

Hello @PatrickLang and greetings from Germany.

I just worked on getting Debian 12 (bookworm) in Hyper-V (Win11) to run in 3840x2160 resolution.

I used
Set-VMVideo -VMName "TheNameOfTheVM" -HorizontalResolution 3840 -VerticalResolution 2160 -ResolutionType Single
on the VM (switched off, PowerShell in Administrator-Mode).

In the Grub-File:
I changed
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:3840x2160"
to
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=Virtual-1:3840x2160"


hyperv_fb replaced with Virtual-1

After that, I was able to change the resolution inside the KDE-Desktop.

I don't know if the DRM is used or not.

Maybe that helps with resizing?

grafik

Tschüß :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment