-
Notifications
You must be signed in to change notification settings - Fork 23
Add cpuid hypervisor support to work with virtualization #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm the Ryzen bug described, but cannot comment on the Intel portion. As for the Ryzen changes, I'm not convinced this is the right approach. I don't have the references at hand, but there are semi-standardised and conventional HV CPUID leafs providing things like FSB Frequency (which might be labeled differently), even supported by XNU directly to bypass things like FSB/ARTFrequency property evaluation. This route should be investigated before deciding on the workaround.
You seem to have referenced the incorrect bugreport in your commit message. I think it was supposed to refer to: acidanthera/bugtracker#531
@Download-Fritz You are right, I found some imformation from here:
So we can just get tsc and bus frequency from 0x40000010 and caculate the max-bus-ratio. |
I successfully get correct TSCFrequence and FSBFrequency from VMWare Timing node (0x40000010), although kvm hardcode the FSBFrequency with 1GHz.
I will submit another commit to make it happend. |
19a4a1e
to
03c68e5
Compare
Issue: acidanthera/bugtracker#531 For some reason that some msr not impletement in such hypervisor (QEMU/KVM/VMWare), so some logic may not work fine in a VM. This commit will add cpuid hypervisor support to indicate whether we are under visualization, then we do some tricks to make it work.
03c68e5
to
a18376f
Compare
|
@Download-Fritz No, I just say that it "hardcore" so maybe not much sense to get it from 0x40000010. I know there are many other supervisor like VMWare or Xen so we definately should get if from 0x4000010 instead of hard code it. I'm just saying, not quite a problem for me. |
I agree with the timing node suggestion, please do that. Given the scope of the change we can handle it within this pull request for simplicity. |
ed7adbd
to
25cfbba
Compare
According to these links: 1. [CPUID usage for interaction between Hypervisors and Linux.](https://lwn.net/Articles/301888/) 2. [[Qemu-devel] [PATCH v2 0/3] x86-kvm: Fix Mac guest timekeeping by exposi](https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg04344.html) There is a "VMWare Timing" Node located at 0x40000010 where we can get TSC/FSB Frequency.It is more sensable than get those freq in MSR which most hypervisor not implemented yet (KVM/VMWare).
25cfbba
to
7d11001
Compare
Commit have updated to support VMWare Timing node. |
maybe we should check 0x4000000 first to see if kvm exposed. |
0301f1f
to
95c8535
Compare
BTW, is there any difference between different bus ratio for MacOS in a VM? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I checked the code, and I do not believe I have issues code wise. However, there are several issues style wise and English-wise:
- Virtualization (not visualization)
- Comment style
- Indentation should be 2 spaces (not 4 spaces)
I commented on most of the issues inline. Please handle that so we can check once again and merge. Thanks for working on the matter.
I do not know of anything about it. Probably nothing? |
786f48b
to
4b06fed
Compare
Typo updates. We should squash these commits. Also I'm sorry for the coding style and typos. |
4b06fed
to
02385d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes, I will squash the commits upon merge at no issue. There still are more issues left, I marked some inline but unlikely all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some improvements should be made, but I need some advises.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need some linter not to trouble the authors with such stuff, but I spotted more.
@vit9696 I'm so sorry about those stupid mistakes, but I'm not quite familar with these type programming and my IDE is quite simple so I'm not seeing it out. |
…rom VMWare Timing
c2c2b9e
to
4ef4f74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After I add this more accurate procedure to determine whether we've got the frequency already, it still have chance failed some way (like hypervisor didn't expose the VMWare Timing Leaf), then we fallback to the old procedure, and intel part is ok but amd part will crash because of some unsafe dividing.Should we change them in this PR?
This looks good enough to me now, @Download-Fritz do you have any objections to merge it? If not, I would like to do that tomorrow or so. |
acidanthera/bugtracker#531
For some reason that some msr not impletement in such hypervisor (QEMU/KVM/VMWare), so some logic may not work fine in a VM.
This commit will add cpuid hypervisor support to indicate whether we are
under virtualization, then we do some tricks to make it work.
According to these links:
1. CPUID usage for interaction between Hypervisors and Linux.
2. [Qemu-devel] [PATCH v2 0/3] x86-kvm: Fix Mac guest timekeeping by exposi
There is a "VMWare Timing" Node located at 0x40000010 where we can get
TSC/FSB Frequency.It is more sensable than geting those freq from MSR which
most hypervisors not implemented yet (KVM/VMWare).