Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
HermitCore
libhermit-rs
Commits
56b7ca42
Unverified
Commit
56b7ca42
authored
Jun 01, 2020
by
Stefan Lankes
Committed by
GitHub
Jun 01, 2020
Browse files
fix interpretation of hypervisor_info (#73)
- frequency is delivered in KHz (and not Hz) - fix conversion to MhZ
parent
b9a09ede
Changes
1
Show whitespace changes
Inline
Side-by-side
src/arch/x86_64/kernel/processor.rs
View file @
56b7ca42
...
...
@@ -17,6 +17,7 @@ use crate::x86::cpuid::*;
use
crate
::
x86
::
msr
::
*
;
use
core
::
arch
::
x86_64
::
__rdtscp
as
rdtscp
;
use
core
::
arch
::
x86_64
::
_rdtsc
as
rdtsc
;
use
core
::
convert
::
TryInto
;
use
core
::
sync
::
atomic
::
spin_loop_hint
;
use
core
::{
fmt
,
u32
};
...
...
@@ -279,9 +280,11 @@ impl CpuFrequency {
}
unsafe
fn
detect_from_cpuid_hypervisor_info
(
&
mut
self
,
cpuid
:
&
CpuId
)
->
Result
<
(),
()
>
{
const
KHZ_TO_HZ
:
u64
=
1000
;
const
MHZ_TO_HZ
:
u64
=
1000000
;
let
hypervisor_info
=
cpuid
.get_hypervisor_info
()
.ok_or
(())
?
;
let
freq
=
hypervisor_info
.tsc_frequency
()
.ok_or
(())
?
;
let
mhz
=
(
freq
/
1000000u32
)
as
u16
;
let
freq
=
hypervisor_info
.tsc_frequency
()
.ok_or
(())
?
as
u64
*
KHZ_TO_HZ
;
let
mhz
:
u16
=
(
freq
/
MHZ_TO_HZ
)
.try_into
()
.unwrap
()
;
self
.set_detected_cpu_frequency
(
mhz
,
CpuFrequencySources
::
HypervisorTscInfo
)
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment