vmbase: Remove now duplicate hyp::util
The libhyp util module only existed to avoid a circular dependency with
vmbase. Now that the code of the former is part of the latter, the
hyp::util has become unnecessary as its users can use the corresponding
functions/constants provided by vmbase.
Test: -
Change-Id: I26331f4998ac0167b1701e4f8a0ddb48122373db
diff --git a/vmbase/src/hyp.rs b/vmbase/src/hyp.rs
index 103d28f..1461f80 100644
--- a/vmbase/src/hyp.rs
+++ b/vmbase/src/hyp.rs
@@ -16,7 +16,6 @@
mod error;
mod hypervisor;
-mod util;
pub use error::{Error, Result};
pub use hypervisor::{
diff --git a/vmbase/src/hyp/hypervisor/common.rs b/vmbase/src/hyp/hypervisor/common.rs
index de564a8..c1995af 100644
--- a/vmbase/src/hyp/hypervisor/common.rs
+++ b/vmbase/src/hyp/hypervisor/common.rs
@@ -14,7 +14,10 @@
//! This module regroups some common traits shared by all the hypervisors.
-use crate::hyp::{util::SIZE_4KB, Error, Result};
+use crate::{
+ hyp::{Error, Result},
+ memory::SIZE_4KB,
+};
/// Expected MMIO guard granule size, validated during MMIO guard initialization.
pub const MMIO_GUARD_GRANULE_SIZE: usize = SIZE_4KB;
diff --git a/vmbase/src/hyp/hypervisor/geniezone.rs b/vmbase/src/hyp/hypervisor/geniezone.rs
index 69ecf41..fcb9b42 100644
--- a/vmbase/src/hyp/hypervisor/geniezone.rs
+++ b/vmbase/src/hyp/hypervisor/geniezone.rs
@@ -17,7 +17,10 @@
use core::fmt::{self, Display, Formatter};
use super::{Hypervisor, MemSharingHypervisor, MmioGuardedHypervisor};
-use crate::hyp::{util::page_address, Error, Result};
+use crate::{
+ hyp::{Error, Result},
+ memory::page_4kb_of,
+};
use smccc::{
error::{positive_or_error_64, success_or_error_64},
@@ -108,14 +111,14 @@
fn map(&self, addr: usize) -> Result<()> {
let mut args = [0u64; 17];
- args[0] = page_address(addr);
+ args[0] = page_4kb_of(addr).try_into().unwrap();
checked_hvc64_expect_zero(VENDOR_HYP_GZVM_MMIO_GUARD_MAP_FUNC_ID, args)
}
fn unmap(&self, addr: usize) -> Result<()> {
let mut args = [0u64; 17];
- args[0] = page_address(addr);
+ args[0] = page_4kb_of(addr).try_into().unwrap();
checked_hvc64_expect_zero(VENDOR_HYP_GZVM_MMIO_GUARD_UNMAP_FUNC_ID, args)
}
diff --git a/vmbase/src/hyp/hypervisor/kvm.rs b/vmbase/src/hyp/hypervisor/kvm.rs
index 8b59234..09fe0ec 100644
--- a/vmbase/src/hyp/hypervisor/kvm.rs
+++ b/vmbase/src/hyp/hypervisor/kvm.rs
@@ -17,7 +17,10 @@
use core::fmt::{self, Display, Formatter};
use super::{DeviceAssigningHypervisor, Hypervisor, MemSharingHypervisor, MmioGuardedHypervisor};
-use crate::hyp::{util::page_address, Error, Result};
+use crate::{
+ hyp::{Error, Result},
+ memory::page_4kb_of,
+};
use smccc::{
error::{positive_or_error_64, success_or_error_32, success_or_error_64},
@@ -112,7 +115,7 @@
fn map(&self, addr: usize) -> Result<()> {
let mut args = [0u64; 17];
- args[0] = page_address(addr);
+ args[0] = page_4kb_of(addr).try_into().unwrap();
// TODO(b/277859415): pKVM returns a i32 instead of a i64 in T.
// Drop this hack once T reaches EoL.
@@ -122,7 +125,7 @@
fn unmap(&self, addr: usize) -> Result<()> {
let mut args = [0u64; 17];
- args[0] = page_address(addr);
+ args[0] = page_4kb_of(addr).try_into().unwrap();
// TODO(b/277860860): pKVM returns NOT_SUPPORTED for SUCCESS in T.
// Drop this hack once T reaches EoL.
diff --git a/vmbase/src/hyp/util.rs b/vmbase/src/hyp/util.rs
deleted file mode 100644
index 56f94fd..0000000
--- a/vmbase/src/hyp/util.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2023, The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//! Utility functions.
-
-pub(crate) const SIZE_4KB: usize = 4 << 10;
-
-/// Computes the low memory page address of the 4KiB page containing a given address.
-pub(crate) fn page_address(addr: usize) -> u64 {
- (addr & !(SIZE_4KB - 1)).try_into().unwrap()
-}