Skip to content

Commit 7eb2b58

Browse files
committed
[refactor] modify guest_phys_to_host_phys
1 parent 6cca839 commit 7eb2b58

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/page_table.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,14 @@ impl<PTE: GenericPTE, H: PagingHandler, EPT: EPTTranslator> GuestPageTable64<PTE
129129
// private implements
130130
impl<PTE: GenericPTE, H: PagingHandler, EPT: EPTTranslator> GuestPageTable64<PTE, H, EPT> {
131131
fn table_of<'a>(&self, gpa: GuestPhysAddr) -> PagingResult<&'a [PTE]> {
132-
let hpa = EPT::guest_phys_to_host_phys(gpa).ok_or_else(|| {
133-
warn!("Failed to translate GPA {:?}", gpa);
134-
PagingError::NotMapped
135-
})?;
132+
let hpa = EPT::guest_phys_to_host_phys(gpa)
133+
.map(|(hpa, _flags, _pgsize)| hpa)
134+
.ok_or_else(|| {
135+
warn!("Failed to translate GPA {:?}", gpa);
136+
PagingError::NotMapped
137+
})?;
136138
let ptr = H::phys_to_virt(hpa).as_ptr() as _;
137139

138-
// debug!(
139-
// "GuestPageTable64::table_of gpa: {:?} hpa: {:?} ptr: {:p}",
140-
// gpa, hpa, ptr
141-
// );
142-
143140
Ok(unsafe { core::slice::from_raw_parts(ptr, ENTRY_COUNT) })
144141
}
145142

src/vmx/vcpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
348348
addr += read_size;
349349
remained_size -= read_size;
350350

351-
if let Some(hpa) = H::EPTTranslator::guest_phys_to_host_phys(gpa) {
351+
if let Some((hpa, _flags, _pgsize)) = H::EPTTranslator::guest_phys_to_host_phys(gpa) {
352352
let hva_ptr = H::PagingHandler::phys_to_virt(hpa).as_ptr();
353353
for i in 0..read_size {
354354
content.push(unsafe { hva_ptr.add(i).read() });

0 commit comments

Comments
 (0)