在 x86-64 上模拟页面大小为 16 KB 的 Cuttlefish

此设置需要使用 x86_64 Linux 主机。本页介绍了如何在 x86_64 上构建和启动支持 16 KB 页面大小的 Cuttlefish。本页面中的说明假定您的机器中已安装 Cuttlefish 软件包。如需查看安装说明,请参阅安装 Cuttlefish 的第 1 步。

若要启动 Cuttlefish,您可以直接从 Android 持续集成网站下载预构建制品,也可以从 AOSP 构建它们(如果您需要修改源代码)。

内核实现

在 Android 14 6.6 GKI 中,page_size_emulation 补丁系列中添加了对模拟 x86_64 16 KB 页面的支持。在命令行中传递 page_shift=14,即可启用此模拟。带有 _16k 后缀的 x86_64 目标(或带有 _pgagnostic 后缀的旧目标),例如 aosp_cf_x86_64_phone_pgagnostic,默认会传递此选项,并默认在 16 KB 模式下运行。

通过下载制品来启动 Cuttlefish

前往 Android 持续集成网站,并输入 aosp-main-throttled 作为分支名称。点击 aosp_cf_x86_64_phone_pgagnostic 目标的最新 build。现在,请按照安装 Cuttlefish 的第 5 步中的说明操作。

通过从 AOSP 进行构建来启动 Cuttlefish

构建和启动设有与页面无关的目标的 Cuttlefish:

$ mkdir main && cd main
$ repo init -u https://android.googlesource.com/platform/manifest -b main
$ repo sync -c -j32

# Build cf agnostic target.
$ source build/envsetup.sh
$ lunch aosp_cf_x86_64_phone_pgagnostic-trunk_staging-userdebug
$ m

# Launch cf with a kernel with 16 KB page size support.
$ launch_cvd
...
...
VIRTUAL_DEVICE_DISPLAY_POWER_MODE_CHANGED
virtio_input_hid_handle_status: unknown type 20
virtio_input_hid_handle_status: unknown type 20
virtio_input_hid_handle_status: unknown type 20
virtio_input_hid_handle_status: unknown type 20
Generating new secret with slot ID: 4
VIRTUAL_DEVICE_BOOT_STARTED
VIRTUAL_DEVICE_NETWORK_MOBILE_CONNECTED

验证页面大小和启动状态

如需验证页面大小和启动状态,请执行以下操作:

  1. 以 root 身份访问 shell:

    $ adb root
    adbd is already running as root
    $ adb shell
    vsoc_x86_64_pgagnostic:/ #
    
  2. 验证页面大小和启动状态:

    vsoc_x86_64_pgagnostic::/ # getconf PAGE_SIZE
    16384
    vsoc_x86_64_pgagnostic::/ # getprop | grep sys.boot.completed
    sys.boot_completed: 1