Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game loads slowly when using hv #23

Open
thewolfram opened this issue May 22, 2023 · 12 comments
Open

Game loads slowly when using hv #23

thewolfram opened this issue May 22, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@thewolfram
Copy link

thewolfram commented May 22, 2023

hey there, I use hv while playing eft and I noticed that the loot loading stage takes a very long time about 5 minutes, but when I play without hv it loads in 1 minute max. I found on unknowncheats that people also had this problem when they were playing on virtual machines, someone suggested that game spams cpuid while loot is loading, but I'm not sure if thats the true reason
https://www.unknowncheats.me/forum/escape-from-tarkov/490919-stuck-loading-loot-qemu-kvm.html
https://www.unknowncheats.me/forum/escape-from-tarkov/568814-loading-loot-slow-kvm.html

EDIT: also some guy said to use invtsc, this might be related too

@jonomango
Copy link
Owner

@thewolfram Sorry for the late reply! invtsc isn't related to this problem, although the game spamming cpuid is a much more realistic scenario. You can just use the usermode logger and add a HV_LOG_INFO() call somewhere around here that prints the exit reason (make sure to ignore VMCALL exits though!).

@jonomango jonomango added the bug Something isn't working label May 28, 2023
@chiefmasterR
Copy link

chiefmasterR commented May 28, 2023

Its ok, I'm replying from another account because unable to access mine, anyway some guy posted that it is for sure happening because game is spamming cpuid. Do you think its possible to somehow mitigate this?

EDIT: here is the link to his post https://www.unknowncheats.me/forum/3497830-post11.html

@jonomango
Copy link
Owner

Its ok, I'm replying from another account because unable to access mine, anyway some guy posted that it is for sure happening because game is spamming cpuid. Do you think its possible to somehow mitigate this?

It's actually almost impossible to mitigate this with intel CPUs, since cpuid is an unconditional vm-exit (if that really is the cause of the lag). Although, it is possible to emulate the subsequent cpuid instructions after the first vm-exit, which is detailed in a VMware paper, but way too complex for a side project like this.

@chiefmasterR
Copy link

Its ok, I'm replying from another account because unable to access mine, anyway some guy posted that it is for sure happening because game is spamming cpuid. Do you think its possible to somehow mitigate this?

It's actually almost impossible to mitigate this with intel CPUs, since cpuid is an unconditional vm-exit (if that really is the cause of the lag). Although, it is possible to emulate the subsequent cpuid instructions after the first vm-exit, which is detailed in a VMware paper, but way too complex for a side project like this.

I think it would be a good solution to devirtualize CPUs while game is loading and virtualize them back when its finished. Could there be any problems?

@jonomango
Copy link
Owner

Its ok, I'm replying from another account because unable to access mine, anyway some guy posted that it is for sure happening because game is spamming cpuid. Do you think its possible to somehow mitigate this?

It's actually almost impossible to mitigate this with intel CPUs, since cpuid is an unconditional vm-exit (if that really is the cause of the lag). Although, it is possible to emulate the subsequent cpuid instructions after the first vm-exit, which is detailed in a VMware paper, but way too complex for a side project like this.

I think it would be a good solution to devirtualize CPUs while game is loading and virtualize them back when its finished. Could there be any problems?

That's really not a bad idea at all, but you'll essentially have a very easy-to-detect driver loaded before the hypervisor can get started. If you can manage to stay undetected in that short period of time, then it's a great solution, but... at that point you would need to already have an undetected driver, so you might as well just use that and ditch the hypervisor completely 😄.

@chiefmasterR
Copy link

I've got another idea which is get the return address in our cpuid emulation function so we find out who is spamming it, and then ept hook the page and nop the cpuid instruction, still I don't know how good is it.

@jonomango
Copy link
Owner

I've got another idea which is get the return address in our cpuid emulation function so we find out who is spamming it, and then ept hook the page and nop the cpuid instruction, still I don't know how good is it.

That could work, but it would have to be specific to the game/anticheat. A NOP probably wouldn't work, but the idea is good. It just wouldn't work as a general solution.

@chiefmasterR
Copy link

So, I'm currently trying to do what I said, I will log calls inside of emulate_cpuid(), but I have question how do I get the return address?

@jonomango
Copy link
Owner

What do you mean by return address? You can check guest rip in the vmcs to see who called cpuid, but finding the return address would be difficult without unwinding the frame.

@chiefmasterR
Copy link

chiefmasterR commented Jun 11, 2023

I mean just get the address of someone who called cpuid instruction
Should I just do this? vmx_vmread(VMCS_GUEST_RIP);

EDIT: yes it is vmx_vmread(VMCS_GUEST_RIP)

@nulledc0de
Copy link

nulledc0de commented Jan 4, 2024

Its ok, I'm replying from another account because unable to access mine, anyway some guy posted that it is for sure happening because game is spamming cpuid. Do you think its possible to somehow mitigate this?

It's actually almost impossible to mitigate this with intel CPUs, since cpuid is an unconditional vm-exit (if that really is the cause of the lag). Although, it is possible to emulate the subsequent cpuid instructions after the first vm-exit, which is detailed in a VMware paper, but way too complex for a side project like this.

sorry to bump this old post but i’m also running into the issues of it running slow i was curious if you had a link to the VMware paper you were referring to?

@Ivann-n
Copy link

Ivann-n commented Jun 5, 2024

Its ok, I'm replying from another account because unable to access mine, anyway some guy posted that it is for sure happening because game is spamming cpuid. Do you think its possible to somehow mitigate this?

It's actually almost impossible to mitigate this with intel CPUs, since cpuid is an unconditional vm-exit (if that really is the cause of the lag). Although, it is possible to emulate the subsequent cpuid instructions after the first vm-exit, which is detailed in a VMware paper, but way too complex for a side project like this.

I too am interested in this paper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants