intel / gvt-linux

Other
503 stars 94 forks source link

OVMF with Intel GVT-g GOP driver #196

Open reet- opened 2 years ago

reet- commented 2 years ago

Hi,

I'm trying to get [1] working, but I cannot find any documentation on how to do this. As soon as I open the display with virt-viewer or directly in virt-manager, the application closes.

The Intel GVT-g GOP driver in the guest OVMF seems to work:

GvtGop: Intel GVT-g virtual GPU [8086:5917] detected, version 1.0

But I also see a lot of messages in the form of:

GvtGop: EfiBltBufferToVideo destination [80, 119] to [144, 138] ouf of range [1, 1]

It seems that there are some parts on the host missing (Debian Bullseye with Linux kernel 5.10.0-9-amd64, QEMU 5.2+dfsg-11+deb11u1). The host itself uses BIOS boot, not UEFI. Not sure if this is supported.

GVT-g is working in the guest VM if used with OVMF without support for Intel GVT-g GOP (by including the extra vbios_gvt_uefi.rom).

The OVMF as well as the virt-viewer debug output is attached: serial.log virt-viewer.log

Any pointers are much appreciated!

Cheers

[1] - https://listman.redhat.com/archives/edk2-devel-archive/2021-March/msg00234.html

reet- commented 2 years ago

I also see the following kernel warning on the host (WARN_ONCE, therefore easy to miss):

Oct 25 16:12:20 hostname kernel: [  174.550487] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 1 created
Oct 25 16:12:20 hostname kernel: [  174.550563] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 2 created
Oct 25 16:12:20 hostname kernel: [  175.149293] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 1 created
Oct 25 16:12:20 hostname kernel: [  175.150021] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 1 created
Oct 25 16:12:20 hostname kernel: [  175.274659] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 1 created
Oct 25 16:12:21 hostname kernel: [  175.460134] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 1 created
Oct 25 16:12:21 hostname kernel: [  175.460206] i915 0000:00:02.0: [drm:i915_gem_context_create_ioctl [i915]] HW context 2 created
Oct 25 16:12:25 hostname kernel: [  179.596661] ------------[ cut here ]------------
Oct 25 16:12:25 hostname kernel: [  179.596665] i915 0000:00:02.0: VM(1): guest is trying to scaling a plane
Oct 25 16:12:25 hostname kernel: [  179.596738] WARNING: CPU: 2 PID: 3207 at drivers/gpu/drm/i915/gvt/handlers.c:1315 pf_write+0x94/0xa0 [i915]
Oct 25 16:12:25 hostname kernel: [  179.596739] Modules linked in: vhost_net vhost vhost_iotlb tap tun hfs nls_utf8 hfsplus vfat fat isofs udf crc_itu_t cdrom hid_microsoft ff_memless ctr ccm nf_conntrack_netlink xfrm_user xfrm_algo xt_addrtype br_netfilter xt_CHECKSUM xt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp nft_compat nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 vboxnetadp(OE) vboxnetflt(OE) nft_counter vboxdrv(OE) nf_tables nfnetlink bridge stp llc typec_displayport overlay binfmt_misc snd_hda_codec_hdmi snd_hda_codec_realtek mei_hdcp joydev mei_wdt kvmgt snd_hda_codec_generic intel_pmc_core_pltdrv intel_pmc_core intel_rapl_msr snd_soc_skl x86_pkg_temp_thermal intel_powerclamp snd_soc_hdac_hda coretemp snd_hda_ext_core snd_soc_sst_ipc kvm_intel iwlmvm rapl snd_soc_sst_dsp intel_cstate mac80211 snd_soc_acpi_intel_match snd_soc_acpi snd_hda_intel snd_intel_dspcfg soundwire_intel soundwire_generic_allocation intel_uncore libarc4 snd_soc_core snd_compress soundwire_cadence iwlwifi
Oct 25 16:12:25 hostname kernel: [  179.596768]  snd_hda_codec uvcvideo serio_raw snd_hda_core iTCO_wdt intel_pmc_bxt snd_hwdep videobuf2_vmalloc wmi_bmof intel_wmi_thunderbolt iTCO_vendor_support videobuf2_memops soundwire_bus videobuf2_v4l2 videobuf2_common watchdog cfg80211 elan_i2c snd_pcm ee1004 snd_timer sg videodev mc mei_me ucsi_acpi evdev typec_ucsi intel_xhci_usb_role_switch processor_thermal_device intel_rapl_common mei roles intel_pch_thermal intel_soc_dts_iosf typec thinkpad_acpi nvram ledtrig_audio int3403_thermal snd soundcore int340x_thermal_zone ac rfkill int3400_thermal acpi_thermal_rel button acpi_pad i915 vfio_mdev mdev vfio_iommu_type1 vfio drm_kms_helper cec i2c_algo_bit kvm irqbypass msr parport_pc ppdev fuse lp drm parport configfs ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 btrfs blake2b_generic sd_mod uas usb_storage scsi_mod dm_crypt raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor hid_generic usbhid hid raid6_pq libcrc32c crc32c_generic raid1 raid0 multipath
Oct 25 16:12:25 hostname kernel: [  179.596804]  linear md_mod dm_mod crc32_pclmul crc32c_intel ghash_clmulni_intel nvme xhci_pci xhci_hcd e1000e aesni_intel nvme_core t10_pi crc_t10dif libaes crypto_simd usbcore thunderbolt crct10dif_generic cryptd psmouse glue_helper crct10dif_pclmul crct10dif_common ptp pps_core i2c_i801 intel_lpss_pci i2c_smbus intel_lpss idma64 usb_common wmi battery video                                                                                                                                                                                 
Oct 25 16:12:25 hostname kernel: [  179.596821] CPU: 2 PID: 3207 Comm: CPU 0/KVM Tainted: G     U     OE     5.10.0-9-amd64 #1 Debian 5.10.70-1                                                 
Oct 25 16:12:25 hostname kernel: [  179.596823] Hardware name: LENOVO 20L8S05A00/20L8S05A00, BIOS N22ET68W (1.45 ) 05/06/2021                                                                   
Oct 25 16:12:25 hostname kernel: [  179.596853] RIP: 0010:pf_write+0x94/0xa0 [i915]                                                                                                             
Oct 25 16:12:25 hostname kernel: [  179.596854] Code: 48 8b 78 18 4c 8b 67 50 4d 85 e4 75 03 4c 8b 27 e8 b1 ee 47 e4 44 89 e9 4c 89 e2 48 c7 c7 70 a9 e1 c0 48 89 c6 e8 1f c9 6d e4 <0f> 0b eb ad 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 41 57 41 89 f1                                                                                                                                        
Oct 25 16:12:25 hostname kernel: [  179.596855] RSP: 0018:ffffb46b03b03db8 EFLAGS: 00010286                                                                                                     
Oct 25 16:12:25 hostname kernel: [  179.596857] RAX: 0000000000000000 RBX: ffff89e5859c8000 RCX: ffff89e8ee918a08                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596858] RDX: 00000000ffffffd8 RSI: 0000000000000027 RDI: ffff89e8ee918a00                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596858] RBP: 0000000000068180 R08: 0000000000000000 R09: ffffb46b03b03bd8                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596859] R10: ffffb46b03b03bd0 R11: ffffffffa62cb428 R12: ffff89e5af3f0e40                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596860] R13: 0000000000000001 R14: ffffb46b004f9000 R15: 0000000000000000                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596861] FS:  00007f38788ca700(0000) GS:ffff89e8ee900000(0000) knlGS:0000000000000000                                                                    
Oct 25 16:12:25 hostname kernel: [  179.596862] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033                                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596863] CR2: 0000000000000000 CR3: 000000016b926004 CR4: 00000000003726e0                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596863] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596864] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596865] Call Trace:                                                                                                                                     
Oct 25 16:12:25 hostname kernel: [  179.596892]  intel_vgpu_mmio_reg_rw+0x10d/0x4b0 [i915]                                                                                                      
Oct 25 16:12:25 hostname kernel: [  179.596916]  intel_vgpu_emulate_mmio_write+0xab/0x2d0 [i915]                                                                                                
Oct 25 16:12:25 hostname kernel: [  179.596919]  intel_vgpu_rw+0xc5/0x200 [kvmgt]                                                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596921]  intel_vgpu_write+0x164/0x1f0 [kvmgt]                                                                                                           
Oct 25 16:12:25 hostname kernel: [  179.596924]  vfs_write+0xc0/0x260                                                                                                                           
Oct 25 16:12:25 hostname kernel: [  179.596927]  __x64_sys_pwrite64+0x8d/0xc0                                                                                                                   
Oct 25 16:12:25 hostname kernel: [  179.596929]  do_syscall_64+0x33/0x80                                                                                                                        
Oct 25 16:12:25 hostname kernel: [  179.596930]  entry_SYSCALL_64_after_hwframe+0x44/0xa9                                                                                                       
Oct 25 16:12:25 hostname kernel: [  179.596932] RIP: 0033:0x7f388a73d9c7                                                                                                                        
Oct 25 16:12:25 hostname kernel: [  179.596933] Code: 08 89 3c 24 48 89 4c 24 18 e8 55 f3 ff ff 4c 8b 54 24 18 48 8b 54 24 10 41 89 c0 48 8b 74 24 08 8b 3c 24 b8 12 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 04 24 e8 85 f3 ff ff 48 8b                                                                                                                                        
Oct 25 16:12:25 hostname kernel: [  179.596934] RSP: 002b:00007f38788c92a0 EFLAGS: 00000293 ORIG_RAX: 0000000000000012                                                                          
Oct 25 16:12:25 hostname kernel: [  179.596935] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f388a73d9c7                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596936] RDX: 0000000000000004 RSI: 00007f38788c92e8 RDI: 0000000000000029                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596937] RBP: 0000000000000004 R08: 0000000000000000 R09: 00000000ffffffff                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596937] R10: 0000000000068180 R11: 0000000000000293 R12: 0000000000068180                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596938] R13: 0000000082000000 R14: 0000559b716b0cb8 R15: 0000559b716b0bd0                                                                               
Oct 25 16:12:25 hostname kernel: [  179.596939] ---[ end trace 071c95e589b81f15 ]---              
ivellioscolin commented 2 years ago

I'm the author of the IntelGvtGopDxe. IntelGvtGopDxe is nothing but a POC to demo a GOP display in gvt-g, not officially supported with upstream kernel, at least when the POC was cooked. I'm not clear about the latest status since I'm not working on that project right now.

For the original issue you reported, IntelGvtGopDxe is requested to blit but out-of-range. The kernel log indicates the plane is scaled. In most cases, it's due to a non-native resolution is set. You may try to modify some hard-coded values define in the GOP code, and make sure it matches vreg HTOTAL and VTOTAL.

OvmfPkg/IntelGvtGopDxe/Display.h DISPLAY_WIDTH_MAX DISPLAY_HEIGHT_MAX DISPLAY_WIDTH_DEFAULT DISPLAY_HEIGHT_DEFAULT

You probably need another change in gvt to modify the initial value of two vregs (HTOTAL and VTOTAL) at end of emulate_monitor_status_change(), since the two vregs may not reflect the actual timing in vGPU.

The most simply and straight-forward way is to modify above value same as your current vGPU default timing: 1920x1200 for type 1,2,4, and 1024x768 for type 8.