Arc-Compute/LibVF.IO

VM Detection - Genshin Impact

serafk opened this issue · 4 comments

Genshin Impact has identified that a Windows guest is running as a VM using libvf.io

Host system is Ubuntu 20.04.3, fresh install and base updates. Nvidia 2080 Super graphics card and AMD 3900X processor.

nvidia-mdev.yaml

%YAML 1.2
%TAG !n! tag:nimyaml.org,2016:
--- !n!custom:Config 
startintro: true
nographics: true
spice: true
introspect: "looking-glass"
shareddir: !!null ~
connectivity: 
  exposedPorts: 
    - 
      guest: 22
      host: 2222
container: 
  kernel: windows.arc
  state: []
  initialSize: 20
  iso: !!null ~
cpus: 
  cores: 4
  sockets: 1
  threads: 1
  ramAlloc: 8192
gpus: 
  - 
    - 
      maxVRam: 2000
    - 
      minVRam: 1000
    - 
      gpuType: sysfsdev
    - 
      mdevType: ""
    - 
      parentPort: !!null ~
    - 
      devId: hostdev0
    - 
      suffix: Q
nics: []
root: ~/.local/libvf.io
sudo: false
commands: 
  - 
    arg: "-set"
    values: ["device.hostdev0.x-pci-device-id=6960"]

Output of 'arcd start nvidia-mdev.yaml'

/bin/sudo /bin/qemu-system-x86_64 -D /home/kenzie/.local/libvf.io/logs/qemu/a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c-session.txt -no-hpet -nographic -vga none -serial none -parallel none -device qemu-xhci,p2=15,p3=15,id=usb -device virtio-serial-pci,id=virtio-serial0 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -spice port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on -chardev spicevmc,id=charredir0,name=usbredir -device usb-redir,chardev=charredir0,id=redir0 -chardev spicevmc,id=charredir1,name=usbredir -device usb-redir,chardev=charredir1,id=redir1 -device ivshmem-plain,id=shmem0,memdev=ivshmem_kvmfr -object memory-backend-file,id=ivshmem_kvmfr,mem-path=/dev/shm/kvmfr-a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c,size=128M,share=yes -device ivshmem-plain,id=shmem1,memdev=ivshmem_kvmsr -object memory-backend-file,id=ivshmem_kvmsr,mem-path=/dev/shm/kvmsr-a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c,size=2M,share=yes -uuid a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c -machine pc-q35-4.2,accel=kvm,usb=off,vmport=off,dump-guest-core=off -cpu host,ss=on,vmx=on,pcid=on,hypervisor=on,arat=on,tsc-adjust=on,umip=on,md-clear=on,stibp=on,arch-capabilities=on,ssbd=on,xsaveopt=on,pdpe1gb=on,ibpb=on,ibrs=on,amd-stibp=on,amd-ssbd=on,skip-l1dfl-vmentry=on,pschange-mc-no=on,hv-vapic,hv-spinlocks=0x1fff,hv-vendor-id=1234567890ab,kvm=off,topoext=on -rtc clock=host,base=localtime -m 8192 -smp cores=4,threads=1,sockets=1 -hda /home/kenzie/.local/libvf.io/kernel/windows.arc --enable-kvm -device vfio-pci,id=hostdev0,sysfsdev=/sys/bus/mdev/devices/ad5d139a-5f43-432d-94c2-72314d506bc1,display=off -device rtl8139,netdev=net0 -netdev user,id=net0,hostfwd=tcp::2222-:22 -qmp unix:/tmp/sockets/a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c/main.sock,server,nowait -qmp unix:/tmp/sockets/a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c/master.sock,server,nowait -set device.hostdev0.x-pci-device-id=6960
char device redirected to /dev/pts/1 (label charserial0)
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ss [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.md-clear [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.ibrs [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ss [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.md-clear [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.ibrs [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ss [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.md-clear [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.ibrs [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ss [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.md-clear [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.ibrs [bit 14]
qemu-system-x86_64: -device vfio-pci,id=hostdev0,sysfsdev=/sys/bus/mdev/devices/ad5d139a-5f43-432d-94c2-72314d506bc1,display=off: warning: vfio ad5d139a-5f43-432d-94c2-72314d506bc1: Could not enable error recovery for the device
[2021-11-29 22:08:12] - INFO: Connecting to the socket
/usr/local/bin/looking-glass-client -f /dev/shm/kvmfr-a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c -a yes egl:scale 1 -m 58 input:rawMouse yes input:captureOnly yes spice:captureOnStart yes win:title=Looking Glass + LibVF.IO (CapsLock toggles input | Hold CapsLock for menu) UUID: a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c
/usr/local/bin/scream -m /dev/shm/kvmsr-a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c
[I]  14154843678              main.c:1064 | main                           | Looking Glass (B4+)
[I]  14154843697              main.c:1065 | main                           | Locking Method: Atomic
[W]  14154865815            option.c:301  | option_parse                   | Ignored invalid argument: yes
[W]  14154865828            option.c:329  | option_parse                   | Ignored invalid argument, missing value: egl:scale
[W]  14154865832            option.c:301  | option_parse                   | Ignored invalid argument: 1
[W]  14154865836            option.c:301  | option_parse                   | Ignored invalid argument: yes
[W]  14154865838            option.c:301  | option_parse                   | Ignored invalid argument: yes
[W]  14154865840            option.c:301  | option_parse                   | Ignored invalid argument: yes
[I]  14154865873           ivshmem.c:127  | ivshmemOpenDev                 | KVMFR Device     : /dev/shm/kvmfr-a96ccb76-36c5-4ef1-a469-c7ce9bf34b1c
[I]  14154899328               egl.c:274  | egl_initialize                 | Double buffering is off
[I]  14154899335              main.c:671  | tryRenderer                    | Using Renderer: EGL
[I]  14154900243               x11.c:303  | x11Init                        | X11 XInput 2.0 in use
[I]  14154903485               x11.c:925  | x11GetEGLDisplay               | Using eglGetPlatformDisplayEXT
[I]  14154917466               egl.c:634  | egl_render_startup             | Multisampling enabled, max samples: 4
[I]  14154925427               egl.c:685  | egl_render_startup             | Single buffer mode
[I]  14154955034               egl.c:701  | egl_render_startup             | EGL       : 1.5
[I]  14154955045               egl.c:702  | egl_render_startup             | Vendor    : NVIDIA Corporation
[I]  14154955048               egl.c:703  | egl_render_startup             | Renderer  : GeForce RTX 2080 SUPER/PCIe/SSE2
[I]  14154955050               egl.c:704  | egl_render_startup             | Version   : OpenGL ES 3.2 NVIDIA 460.73.01
[I]  14154955052               egl.c:705  | egl_render_startup             | EGL APIs  : OpenGL_ES OpenGL
[I]  14154955054               egl.c:706  | egl_render_startup             | Extensions: EGL_EXT_buffer_age EGL_EXT_client_sync EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_MESA_image_dma_buf_export EGL_EXT_output_base EGL_EXT_stream_acquire_mode EGL_EXT_sync_reuse EGL_IMG_context_priority EGL_KHR_config_attribs EGL_KHR_create_context_no_error EGL_KHR_context_flush_control EGL_KHR_create_context EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_partial_update EGL_KHR_swap_buffers_with_damage EGL_KHR_no_config_context EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_reusable_sync EGL_KHR_stream EGL_KHR_stream_attrib EGL_KHR_stream_consumer_gltexture EGL_KHR_stream_cross_process_fd EGL_KHR_stream_fifo EGL_KHR_stream_producer_eglsurface EGL_KHR_surfaceless_context EGL_KHR_wait_sync EGL_NV_nvrm_fence_sync EGL_NV_post_sub_buffer EGL_NV_quadruple_buffer EGL_NV_stream_consumer_eglimage EGL_NV_stream_cross_display EGL_NV_stream_cross_object EGL_NV_stream_cross_process EGL_NV_stream_cross_system EGL_NV_stream_dma EGL_NV_stream_flush EGL_NV_stream_metadata EGL_NV_stream_remote EGL_NV_stream_reset EGL_NV_stream_socket EGL_NV_stream_socket_inet EGL_NV_stream_socket_unix EGL_NV_stream_sync EGL_NV_stream_fifo_next EGL_NV_stream_fifo_synchronous EGL_NV_stream_consumer_gltexture_yuv EGL_NV_stream_attrib EGL_NV_stream_origin EGL_NV_system_time EGL_NV_output_drm_flip_event EGL_NV_triple_buffer EGL_WL_bind_wayland_display EGL_WL_wayland_eglstream
[W]  14154955063               egl.c:721  | egl_render_startup             | NVIDIA driver detected, ignoring broken DMA support
[I]  14155158034              main.c:897  | lg_run                         | ================================================================================
[I]  14155158049              main.c:898  | lg_run                         | The host application seems to not be running
[I]  14155158052              main.c:899  | lg_run                         | Waiting for the host application to start...
[I]  14180159767              main.c:954  | lg_run                         | Host ready, reported version: B4+
[I]  14180159783              main.c:955  | lg_run                         | Starting session
[I]  14180262364              main.c:498  | main_frameThread               | Format: FRAME_TYPE_BGRA 2560x1440 stride:2560 pitch:10240 rotation:0
[I]  14181819009              main.c:498  | main_frameThread               | Format: FRAME_TYPE_BGRA 2560x1440 stride:2560 pitch:10240 rotation:0
[I]  14182067999              main.c:498  | main_frameThread               | Format: FRAME_TYPE_BGRA 2560x1440 stride:2560 pitch:10240 rotation:0
[I]  14191385573              main.c:498  | main_frameThread               | Format: FRAME_TYPE_BGRA 2560x1440 stride:2560 pitch:10240 rotation:0
Switched format to sample rate 48000, sample size 32 and 2 channels.
[I]  14201153389              main.c:498  | main_frameThread               | Format: FRAME_TYPE_BGRA 2560x1440 stride:2560 pitch:10240 rotation:0
[I]  14202853735              main.c:498  | main_frameThread               | Format: FRAME_TYPE_BGRA 2560x1440 stride:2560 pitch:10240 rotation:0

From what I've been reading with regards to Genshin Impact specifically in a VM they do a simple VM check that is normally defeated by libvrt's feature policy='disable' name='hypervisor' setting. I am unsure how to validate that that is being done when calling Qemu directly like arcd is and I would have assumed this would be covered in the general hypervisor detection preventions as was mentioned by @arthurrasmusson on the r/homelab subreddit.

Unsure if this last bit is worth mentioning, but as this is something of a test for me (Genshin is the last hold-out keeping me on Windows), I am running Ubuntu off of a USB3.1 SSD. Getting some pretty harsh disk access issues but for the purpose of the test that's fine (provided the game actually launches).

@serafk Thanks for bringing this to my attention. I found out Halo Infinite looks for some things that might be checking for a QEMU Machine Protocol (QMP) socket to detect the hypervisor as well. I'm going to try to create a more aggressive hypervisor hidden mode depending on if we have to sacrifice some functionality to make these games work. I'll do my best to test against Genshin Impact as well as Halo Infinite while I'm working on this.
Related:
https://forums.unraid.net/topic/116106-halo-infinite-cant-start/

Mind trying this for me

Do this in your libvf.io folder.

  1. Replace hv-vendor-id=1234567890ab with hv_vendor_id=null at https://github.com/Arc-Compute/libvf.io/blob/67bffe1958bbfdfb72ac5ea10c0f19b836804a75/src/libvfio/control/arguments.nim#L48
  2. Replace hypervisor=on with -hypervisor at https://github.com/Arc-Compute/libvf.io/blob/67bffe1958bbfdfb72ac5ea10c0f19b836804a75/src/libvfio/control/arguments.nim#L30
  3. Add "hv_time" after the comma https://github.com/Arc-Compute/libvf.io/blob/67bffe1958bbfdfb72ac5ea10c0f19b836804a75/src/libvfio/control/arguments.nim#L46
  4. Run nimble install -y

You may need to reinstall the windows VM, but it should hopefully fix the hypervisor checks.

Let me know if you need any more help here.

This worked! Thanks very much. Pretty minimal adjustment, though unsure of whether or not there's a performance hit compared to the normal defaults.

Some noticeable lag but I suspect that this is more due to it running off an old SSD via USB.

Let us know if there are issues