自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
Android 虚拟化框架 (AVF) 概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 虚拟化框架 (AVF) 提供安全且私密的执行环境来执行代码。AVF 非常适合以安全为导向的用例,这些用例需要比 Android 应用沙盒提供的安全系数更高、甚至经过正式验证的隔离保证。Android 提供了实现 AVF 所需的所有组件的参考实现。目前,只有 ARM64 设备支持 AVF。图 1 显示了 AVF 的架构:
图 1. AVF 架构
以下是图 1 中最重要的术语的定义:
- apexd 和 zipfuse
- 安全地装载从主机导入的 APEX 和 APK。
- authfs
- 一个融合文件系统,用于在 Android 和 pVM(主机和客户机)之间安全地共享多个文件。
- binder
- 虚拟机间通信的主要方式。
- crosvm
- 一个以 Rust 编写的虚拟机监视器。crosvm 分配虚拟机内存、创建虚拟 CPU 线程,以及实现虚拟设备的后端。
- 通用内核映像 (GKI)
- 经过 Google 认证的启动映像,其中包含基于 Android 通用内核 (ACK) 源代码树构建的 GKI 内核,适合刷写到 Android 设备的启动分区。如需了解详情,请参阅内核概览。
- Hypervisor
- AVF 使用的虚拟化技术,也称为 pKVM。即使主机 Android 或任何其他 pVM 遭到入侵,Hypervisor 仍可保持已执行代码的完整性和 pVM 资源的机密性。
- Java API
- VirtualizationService Java API,仅存在于支持 AVF 的设备上。这些 API 是可选的,不属于
thebootclasspath
。
- Microdroid
- Google 提供的在 pVM 中运行的迷你版 Android OS。
- Microdroid 管理器
- 管理 pVM 内的 pVM 生命周期,以及实例磁盘。
- 原生 API
- Android 原生开发者套件 (NDK) 的一个子集。
- 基于内核的受保护虚拟机 (pKVM)
- 请参阅 Hypervisor。
- pVM 固件 (
pvmfw
)
- 在 pVM 上运行的第一个代码,
pvmfw
会验证载荷并推导每个虚拟机的 Secret。 - 受保护的虚拟机 (pVM)
一种互不信任的隔离执行环境(客户机),与主 Android 操作系统(主机)一起运行。pVM 安全的一个重要方面是,即使主机遭到入侵,主机也无法访问 pVM 的内存。pKVM 是运行 pVM 的标准 Hypervisor。
与现有的可信执行环境 (TEE) 相比,pVM 可提供更丰富的环境,包括能够运行一个名为 Microdroid 的迷你版 Android 分发平台(尽管 Microdroid 也可以在未受保护的虚拟机上运行)。pVM 可以动态使用,并且在可信环境中提供一组标准 API,供所有支持它们的设备使用。
- VirtualizationService
管理 pVM 生命周期的 Android 服务。
后续操作
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-04。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-04。"],[],[],null,["# Android Virtualization Framework (AVF) overview\n\n*Android Virtualization Framework (AVF)* provides secure and private execution\nenvironments for executing code. AVF is ideal for security-oriented use cases\nthat require stronger, even formally verified, isolation assurances over those\noffered by Android's app sandbox. Android provides a reference implementation\nof all the components needed to implement AVF. AVF is supported only\non ARM64 devices. Figure 1 shows the architecture of AVF:\n\n**Figure 1.** AVF architecture.\n\nHere are the definitions for the most important terms from figure 1:\n\n*apexd and zipfuse*\n: Securely mounts APEXes and APKs imported from host.\n\n*authfs*\n: A fuse file system for securely sharing multiple files between Android and pVM\n (host and guest).\n\n*binder*\n: Primary means of inter-VM communication.\n\n*crosvm*\n: A virtual machine monitor written in rust. crosvm allocates VM memory,\n creates virtual CPU threads, and implements the virtual device's back-ends.\n\n*Generic Kernel Image (GKI)*\n: A boot image certified by Google that contains a GKI kernel built from an\n Android Common Kernel (ACK) source tree and is suitable to be flashed to the\n boot partition of an Android device. For further information, see the [Kernel\n overview](/docs/core/architecture/kernel).\n\n*hypervisor*\n: The virtualization technology used by AVF, also known as *pKVM*. The\n hypervisor maintains the integrity of the executed code and confidentiality of\n the pVM's assets, even if host Android or any of the other pVMs are compromised.\n\n*Java API*\n: The VirtualizationService Java APIs, which are present only on devices with\n AVF support. These APIs are optional and not part of `thebootclasspath`.\n\n*Microdroid*\n: A Google-provided mini-Android OS that runs in a pVM.\n\n*Microdroid Manager*\n: Manages the pVM lifecycle, inside the pVM, and instance disk.\n\n*Native API*\n: A subset of the Android Native Developers Kit (NDK).\n\n*protected kernel-based virtual machine (pKVM)*\n: See [Hypervisor](#hyper).\n\n*pVM firmware (`pvmfw`)*\n: The first code that runs on a pVM, `pvmfw` verifies the payload and derives\n the per-VM secret.\n\n*protected virtual machine (pVM)*\n\n: A mutually distrusted isolated execution environment (*guest* ) that runs\n alongside the main Android operating system (*host*). One important aspect of\n pVM security is even if the host is compromised, the host doesn't have access\n to a pVM's memory. pKVM is the standard hypervisor for running pVMs.\n\n Compared to existing trusted execution environments (TEEs), pVMs provide a\n richer environment, including the ability to run a mini-Android distribution\n called [Microdroid](#micro) (though Microdroid can also run on an\n unprotected VM). pVMs can be used dynamically and provide a\n standard set of APIs in a trusted environment available across all devices\n that support them.\n\n*VirtualizationService*\n\n: The Android service that manages the lifecycle of pVMs.\n\nWhat's next?\n------------\n\n- If you want to better understand the need for AVF, refer to [Why AVF?](/docs/core/virtualization/whyavf).\n- To read about how AVF can be used for isolated compilation, refer to [Use cases](/docs/core/virtualization/usecases).\n- If you want a more in-depth explanation of the AVF reference implementation's architecture, refer to [AVF architecture](/docs/core/virtualization/architecture).\n- If you want to learn about Microdroid, refer to [Microdroid](/docs/core/virtualization/microdroid).\n- If you are interested in how AVF handles security, refer to [Security](/docs/core/virtualization/security).\n- To understand the role of the virtualization service, refer to [VirtualizationService](/docs/core/virtualization/virtualization-service).\n- For source code of AVF or in-depth explanation about individual components, refer to [AOSP\n repository](https://android.googlesource.com/platform/packages/modules/Virtualization/+/refs/heads/main)"]]