mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
hypervisor: haxm: fix segment limits
Similar to WHPX, it looks like HAXM's segment_desc_t structure exactly
mirrors the Intel VMCS, where segment limits are always represented in
bytes.
From the Intel SDM Vol. 3, 25.4.1 ("Guest Register State"):
> Segment limit (32 bits). The limit field is always a measure in bytes.
Fixes: 2fc3047b9b
("hypervisor: x86_64: clarify Segment limit units")
Change-Id: I533216ea2359d1702d72cae0192e11e0478cf2c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5751215
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Oystein Eftevaag <oysteine@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
This commit is contained in:
parent
81a61ee910
commit
ad7bf30508
1 changed files with 3 additions and 14 deletions
|
@ -778,15 +778,9 @@ impl From<&segment_desc_t> for Segment {
|
|||
// TODO(b/315998194): Add safety comment
|
||||
#[allow(clippy::undocumented_unsafe_blocks)]
|
||||
unsafe {
|
||||
let g = item.__bindgen_anon_1.__bindgen_anon_1.granularity() as u8;
|
||||
let limit_bytes = if g == 0 {
|
||||
item.limit
|
||||
} else {
|
||||
(item.limit * 4096) + 4095
|
||||
};
|
||||
Segment {
|
||||
base: item.base,
|
||||
limit_bytes,
|
||||
limit_bytes: item.limit,
|
||||
selector: item.selector,
|
||||
type_: item.__bindgen_anon_1.__bindgen_anon_1.type_() as u8,
|
||||
present: item.__bindgen_anon_1.__bindgen_anon_1.present() as u8,
|
||||
|
@ -794,7 +788,7 @@ impl From<&segment_desc_t> for Segment {
|
|||
db: item.__bindgen_anon_1.__bindgen_anon_1.operand_size() as u8,
|
||||
s: item.__bindgen_anon_1.__bindgen_anon_1.desc() as u8,
|
||||
l: item.__bindgen_anon_1.__bindgen_anon_1.long_mode() as u8,
|
||||
g,
|
||||
g: item.__bindgen_anon_1.__bindgen_anon_1.granularity() as u8,
|
||||
avl: item.__bindgen_anon_1.__bindgen_anon_1.available() as u8,
|
||||
}
|
||||
}
|
||||
|
@ -803,14 +797,9 @@ impl From<&segment_desc_t> for Segment {
|
|||
|
||||
impl From<&Segment> for segment_desc_t {
|
||||
fn from(item: &Segment) -> Self {
|
||||
let limit = if item.g == 0 {
|
||||
item.limit_bytes
|
||||
} else {
|
||||
item.limit_bytes / 4096
|
||||
};
|
||||
let mut segment = segment_desc_t {
|
||||
base: item.base,
|
||||
limit,
|
||||
limit: item.limit_bytes,
|
||||
selector: item.selector,
|
||||
..Default::default()
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue