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

Division by zero on TSC calculation when running on Virtualbox 6 #29

Open
alex-ab opened this issue Sep 16, 2024 · 0 comments
Open

Division by zero on TSC calculation when running on Virtualbox 6 #29

alex-ab opened this issue Sep 16, 2024 · 0 comments

Comments

@alex-ab
Copy link

alex-ab commented Sep 16, 2024

Thanks for your nice tool! Much enjoyed it during our AVX enablement of Vbox6 on our OS.

During testing it on our port and also on a vanilla Linux VM (Debian) on a Linux (Ubuntu 22.04) + Virtualbox6 host, a division by zero happens. It seems Virtualbox 6 does not provide all the expected CPUID values you need. The following patch avoids the issue and instead the TSC frequency is measured and avx-turbo works afterwards.

--- a/tsc-support.cpp
+++ b/tsc-support.cpp
@@ -41,7 +41,7 @@ uint64_t get_tsc_from_cpuid_inner() {
 
 
     if (family.family == 6) {
-        if (family.model == 0x4E || family.model == 0x5E || family.model == 0x8E || family.model == 0x9E) {
+        if (cpuid15.eax && (family.model == 0x4E || family.model == 0x5E || family.model == 0x8E || family.model == 0x9E)) {
             // skylake client or kabylake
             return (int64_t)24000000 * cpuid15.ebx / cpuid15.eax; // 24 MHz crystal clock
         }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant