Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 344dc46d authored by Nikita Ioffe's avatar Nikita Ioffe
Browse files

Add noop implementation of the IVmCapabilitiesService

This implementation will be used in cuttlefish for mixed device testing.

Unfortunately, cuttlefish can't use the default implementation, since
it neither doesn't support pVMs not runs pkvm as hypervisor.

Additionally, this patch adds a simple VTS test to ensure that HAL was
setup correctly.

Bug: 360102915
Test: atest VtsVmCapabilitiesServiceTest
Test: presubmit
Test: manually add noop service to husky
Change-Id: I03ed5b10063ba942704ae5599435a2378a4df63d
parent dadf24a0
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
The IVmCapabilitiesService HAL is used in a flow to grant a pVM a capability to
issue vendor-specific SMCs. For more information see: TODO(ioffe): link the docs

Here is a brief overview of the subdirectories structure:

* default/ - a reference implementation of the HAL that partners can integrate
    in their products.
* noop/ - a no-op implementation is used in cuttlefish for mixed build testing.
* vts/ - VTS tests for this HAL.
+34 −0
Original line number Diff line number Diff line
package {
    default_team: "trendy_team_virtualization",
    default_applicable_licenses: ["Android-Apache-2.0"],
}

rust_binary {
    name: "android.hardware.virtualization.capabilities.capabilities_service-noop",
    relative_install_path: "hw",
    vendor: true,
    installable: true,
    prefer_rlib: true,
    rustlibs: [
        "android.hardware.virtualization.capabilities.capabilities_service-V1-rust",
        "libanyhow",
        "libandroid_logger",
        "libbinder_rs",
        "liblog_rust",
    ],
    srcs: [
        "src/main.rs",
    ],
    init_rc: [
        "android.hardware.virtualization.capabilities.no_op_vm_capabilities_service.rc",
    ],
    vintf_fragment_modules: [
        "android.hardware.virtualization.capabilities.no_op_vm_capabilities_service.xml",
    ],
}

vintf_fragment {
    name: "android.hardware.virtualization.capabilities.no_op_vm_capabilities_service.xml",
    src: "android.hardware.virtualization.capabilities.no_op_vm_capabilities_service.xml",
    vendor: true,
}
+6 −0
Original line number Diff line number Diff line
service vendor.vm_capabilities_service /vendor/bin/hw/android.hardware.virtualization.capabilities.capabilities_service-noop
  interface aidl android.hardware.virtualization.capabilities.IVmCapabilitiesService/noop
  class hal
  disabled
  user nobody
  group nobody
+10 −0
Original line number Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="aidl">
        <name>android.hardware.virtualization.capabilities</name>
        <version>1</version>
        <interface>
            <name>IVmCapabilitiesService</name>
            <instance>noop</instance>
        </interface>
    </hal>
</manifest>
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

//! No-op implementation of the IVmCapabilitiesService AIDL interface.

use android_hardware_virtualization_capabilities_capabilities_service::aidl::android::hardware::virtualization::capabilities::IVmCapabilitiesService::IVmCapabilitiesService;
use binder::{Interface, ParcelFileDescriptor};
use log::info;

/// No-op implementation of IVmCapabilitiesService
pub struct NoOpVmCapabilitiesService {}

impl NoOpVmCapabilitiesService {
    pub fn init() -> NoOpVmCapabilitiesService {
        let service = NoOpVmCapabilitiesService {};
        service
    }
}

impl Interface for NoOpVmCapabilitiesService {}

impl IVmCapabilitiesService for NoOpVmCapabilitiesService {

    fn grantAccessToVendorTeeServices(&self,
        vm_fd: &ParcelFileDescriptor, tee_services: &[String]) -> binder::Result<()> {
        info!("received {vm_fd:?} {tee_services:?}");
        Ok(())
    }
}
Loading