自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Android 虛擬化架構 (AVF) 總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 虛擬化架構 (AVF) 可提供安全且私密的執行環境,用於執行程式碼。AVF 非常適合以安全為導向的用途,因為這些用途需要比 Android 應用程式沙箱提供的更強大、甚至是經過正式驗證的隔離保證。Android 提供實作參考資料,其中包含實作 AVF 所需的所有元件。AVF 僅支援 ARM64 裝置。圖 1 顯示 AVF 的架構:
圖 1. AVF 架構。
以下是圖 1 中最重要的術語定義:
- apexd 和 zipfuse
- 安全地掛載從主機匯入的 APEX 和 APK。
- authfs
- Fuse 檔案系統,可在 Android 和 pVM (主機和來賓) 之間安全地共用多個檔案。
- binder
- VM 間通訊的主要方式。
- crosvm
- 以 rust 編寫的虛擬機器監視器。crosvm 會分配 VM 記憶體、建立虛擬 CPU 執行緒,並實作虛擬裝置的後端。
- 通用核心映像檔 (GKI)
- 由 Google 認證的開機映像檔,其中包含從 Android 通用核心 (ACK) 來源樹建構的 GKI 核心,適合刷入 Android 裝置的啟動分割區。詳情請參閱「核心總覽」。
- hypervisor
- AVF 使用的虛擬化技術,也稱為 pKVM。即使主機 Android 或任何其他 pVM 遭到入侵,輔助執行緒仍可維持執行程式碼的完整性,以及 pVM 資產的機密性。
- Java API
- VirtualizationService Java API,僅適用於支援 AVF 的裝置。這些 API 為選用項目,並非
thebootclasspath
的一部分。
- Microdroid
- Google 提供的 mini-Android OS,可在 pVM 中執行。
- Microdroid Manager
- 管理 pVM 內部和執行個體磁碟的 pVM 生命週期。
- 原生 API
- Android Native Development Kit (NDK) 的子集。
- 以核心為基礎的受保護虛擬機器 (pKVM)
- 請參閱「Hyper-V 虛擬機器」。
- pVM 韌體 (
pvmfw
)
- 在 pVM 上執行的第一個程式碼
pvmfw
會驗證酬載,並衍生每個 VM 的密鑰。 - 受保護的虛擬機器 (pVM)
與主要 Android 作業系統 (主機) 一同執行的互不信任隔離執行環境 (訪客)。pVM 安全性有一項重要層面,即即使主機遭到入侵,主機也無法存取 pVM 的記憶體。pKVM 是執行 pVM 的標準管理程序。
與現有的受信任執行環境 (TEE) 相比,pVM 可提供更豐富的環境,包括執行名為 Microdroid 的迷你 Android 發行版本 (雖然 Microdroid 也可以在未受保護的 VM 上執行)。pVM 可動態使用,並在受信任的環境中提供一組標準 API,可供所有支援的裝置使用。
- VirtualizationService
管理 pVM 生命週期的 Android 服務。
後續步驟
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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)"]]