Android HLOS 從前一階段收到 CDI 值和 DICE 鏈結後,會讀取這些值,然後衍生並清除 SDV 服務探索所需的必要密碼 (例如公開和私密金鑰配對,以及進一步的 CDI 階段)。
這項程序會在開機流程中盡快進行,也就是在early-init的第二階段初始化期間。這麼做可確保 Android HLOS 會在任何第三方程式碼執行前,使用並清除 CDI 值。
Android 系統啟動載入程式 (或 Hypervisor 中的訪客載入程式,如果沒有 Android 系統啟動載入程式) 會透過 SDV 的 Linux 核心,將下列值傳遞至 Android 使用者空間中的 second stage init:
- Android HLOS 層的認證 CDI 值。
- Android HLOS 層的 CDI 值密封。
- CBOR 編碼的 DICE 鏈結,直到 Android HLOS 層。
這些值採用 SdvDiceHandover 格式。SdvDiceHandover 是以 CBOR 編碼的地圖,由以下 CDDL 片段說明:
SdvDiceHandover = {
1 : bstr .size 32, ; CDI_Attest
2 : bstr .size 32, ; CDI_Seal
3 : DiceCertChain, ; Android SDV DICE chain
}
IRemotelyProvisionedComponent HAL DiceCertChain 會指定 DiceCertChain 的格式。SdvDiceHandover 不需要以決定性方式編碼的 CBOR,但強烈建議您這麼做,因為這樣可支援更多 DICE 政策。
SdvDiceHandover 格式與下列格式非常相似:
Open Profile for DICE 參考實作定義的
AndroidDiceHandover格式。PvmfwDiceHandover格式,pvmfw會使用這個格式將 DICE 鏈結交給 pVM,例如 Microdroid。
與 AndroidDiceHandover 相反,DiceCertChain 與 PvmfwDiceHandover 格式類似,是必要格式,而非選用格式。
開啟 DICE 核心驅動程式的設定檔
Android Bootloader (或沒有 Bootloader 時,管理程序中的訪客載入器) 將 Android HLOS CDI 交接給 Android HLOS 時,會用到 Open Profile for DICE kernel driver。Android Bootloader 會將 DICE 鏈結項目寫入訪客記憶體中的區域,而裝置樹狀結構 (DT) 必須指定該區域。
驅動程式會讀取 DT 指定的記憶體區域,並以 /dev/open-dice0 裝置的形式向使用者空間公開。驅動程式可讀取及清除這個記憶體區域。DICE 驅動程式的開放式設定檔僅適用於 arm64 架構,因為裝置樹狀架構是 arm64 專屬概念。
使用 DT 中的 reserved-memory 節點指定 Open Profile for DICE 驅動程式公開的記憶體區域,方法是在 compatible 屬性中指定 "google,open-dice",為驅動程式加上標記。例如:
reserved-memory {
// The number of u32 cells to represent the address of a memory region
#address-cells = <2>;
// The number of u32 cells to represent the size of a memory region
#size-cells = <2>;
ranges;
// The unit address (after the @) must match the address in the reg property
dice@D1C30000 {
compatible = "google,open-dice";
no-map;
// The address and the size of the memory region that is passed to the Open
// Profile for DICE driver. The address must be page-aligned, and the size a
// multiple of the page size. The first two hex numbers (cells) represent
// the address of the memory region, the last two represent its size.
reg = <0x0 0xD1C30000 0x0 0x1000>;
};
};