Merge changes from topic "virtualizationservice_bind_device_to_vfio" into main
* changes:
Bind devices to VFIO with VirtualizationService
Implement platform API to assign devices
diff --git a/compos/tests/AndroidTest.xml b/compos/tests/AndroidTest.xml
index 4b414f1..e35b874 100644
--- a/compos/tests/AndroidTest.xml
+++ b/compos/tests/AndroidTest.xml
@@ -15,6 +15,7 @@
-->
<configuration description="Tests for CompOS">
<option name="config-descriptor:metadata" key="mainline-param" value="com.google.android.art.apex" />
+ <option name="config-descriptor:metadata" key="mainline-param" value="com.android.art.apex" />
<!-- Only run tests if the device under test is SDK version 33 (Android 13) or above. -->
<object type="module_controller"
diff --git a/vmbase/src/bionic.rs b/vmbase/src/bionic.rs
index 29fa0ff..f8db1fe 100644
--- a/vmbase/src/bionic.rs
+++ b/vmbase/src/bionic.rs
@@ -24,9 +24,11 @@
use crate::console;
use crate::cstr;
use crate::eprintln;
+use crate::rand::fill_with_entropy;
use crate::read_sysreg;
const EOF: c_int = -1;
+const EIO: c_int = 5;
/// Bionic thread-local storage.
#[repr(C)]
@@ -85,6 +87,21 @@
unsafe { ERRNO }
}
+#[no_mangle]
+extern "C" fn getentropy(buffer: *mut c_void, length: usize) -> c_int {
+ if length > 256 {
+ // The maximum permitted value for the length argument is 256.
+ set_errno(EIO);
+ return -1;
+ }
+
+ // SAFETY: Just like libc, we need to assume that `ptr` is valid.
+ let buffer = unsafe { slice::from_raw_parts_mut(buffer.cast::<u8>(), length) };
+ fill_with_entropy(buffer).unwrap();
+
+ 0
+}
+
/// Reports a fatal error detected by Bionic.
///
/// # Safety
diff --git a/vmbase/src/memory/shared.rs b/vmbase/src/memory/shared.rs
index f4c9f72..dfa29e4 100644
--- a/vmbase/src/memory/shared.rs
+++ b/vmbase/src/memory/shared.rs
@@ -341,11 +341,7 @@
/// Allocates a memory range of at least the given size and alignment that is shared with the host.
/// Returns a pointer to the buffer.
pub(crate) fn alloc_shared(layout: Layout) -> hyp::Result<NonNull<u8>> {
- // TODO(b/291586508): We have temporarily removed the non-zero check for layout.size() to
- // enable the Rialto socket device to connect or shut down, as the socket driver adds empty
- // buffers in these scenarios.
- // We will add the check back once this issue is fixed in the driver.
-
+ assert_ne!(layout.size(), 0);
let Some(buffer) = try_shared_alloc(layout) else {
handle_alloc_error(layout);
};
diff --git a/vmbase/src/rand.rs b/vmbase/src/rand.rs
index 2acc390..b31bd4b 100644
--- a/vmbase/src/rand.rs
+++ b/vmbase/src/rand.rs
@@ -153,15 +153,3 @@
fill_with_entropy(&mut arr)?;
Ok(arr)
}
-
-#[no_mangle]
-extern "C" fn CRYPTO_sysrand_for_seed(out: *mut u8, req: usize) {
- CRYPTO_sysrand(out, req)
-}
-
-#[no_mangle]
-extern "C" fn CRYPTO_sysrand(out: *mut u8, req: usize) {
- // SAFETY: We need to assume that out points to valid memory of size req.
- let s = unsafe { core::slice::from_raw_parts_mut(out, req) };
- fill_with_entropy(s).unwrap()
-}