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

hermit in uhyve can't read processor frequency #30

Closed
jschwe opened this issue Apr 23, 2020 · 6 comments
Closed

hermit in uhyve can't read processor frequency #30

jschwe opened this issue Apr 23, 2020 · 6 comments

Comments

@jschwe
Copy link
Contributor

jschwe commented Apr 23, 2020

On my system using uhyve hermit fails to read the cpu-frequency with detect_from_cpuid and detect_from_cpid_tsc_info.

The first issue is that detect_from_cpuid can return a frequency of 0, which is Some, but not a valid value. This is fixed by #29.
The second issue I encountered is that detect_from_cpid_tsc_info fails with a panic, due to a division by zero here: https://github.com/gz/rust-cpuid/blob/b64cef2bbfd577b2d3e1c65b8ca76456730efa65/src/lib.rs#L3769
Is this something that should be fixed upstream or should we catch the panic on our side (I'm new to rust but I assume that's possible)?

The next method detect_from_hypervisor works fine for me.

@stlankes
Copy link
Contributor

When do you get the panic? If get_tsc_info doesn't return None, but the frequency isn't correctly evaluated?

@jschwe
Copy link
Contributor Author

jschwe commented Apr 25, 2020

The panic occurs here (inside the rust-cpuid module) : https://github.com/gz/rust-cpuid/blob/b64cef2bbfd577b2d3e1c65b8ca76456730efa65/src/lib.rs#L3769
This is due to a division by zero, which is because eax is apparently zero.

@stlankes
Copy link
Contributor

Can you specify your processor? Maybe the output of lscpu...

@jschwe
Copy link
Contributor Author

jschwe commented Apr 26, 2020

Sure. As you can see below, A virtual ubuntu has no problems reading the basic CPU information from kvm, so uhyve should have access to this information too.

I also want to note that detect_from_hypervisor() only works if uhyve is run on native ubuntu. If uhyve is run on a virtual machine (nested virtualization, see also hermit-os/uhyve#6) this method fails, even though the information is available in the virtual machine. I suspect these two issues might be related in some way.

lscpu native Ubuntu

$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               94
Model name:          Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
Stepping:            3
CPU MHz:             800.017
CPU max MHz:         3900,0000
CPU min MHz:         800,0000
BogoMIPS:            6999.82
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            6144K
NUMA node0 CPU(s):   0-3
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d

lscpu virtualized Ubuntu (kvm hypervisor)

$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               94
Model name:          Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
Stepping:            3
CPU MHz:             3503.998
BogoMIPS:            7007.99
Virtualization:      VT-x
Hypervisor vendor:   KVM
Virtualization type: full
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            6144K
NUMA node0 CPU(s):   0-3
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti tpr_shadow flexpriority fsgsbase avx2 invpcid rdseed clflushopt md_clear flush_l1d

@stlankes
Copy link
Contributor

stlankes commented May 1, 2020

I think that we solved this issue. Can we close it?

@jschwe
Copy link
Contributor Author

jschwe commented May 1, 2020

Yes, the two issues I described here are now solved.

@jschwe jschwe closed this as completed May 1, 2020
simonschoening pushed a commit to simonschoening/libhermit-rs that referenced this issue Aug 26, 2021
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

2 participants