From 88648d33c93715ec83b7c16b875fb33b38a539d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Fri, 24 Sep 2021 15:41:13 +0200 Subject: [PATCH 1/3] Stop assuming that pvmfw.img can only be pre-built Introduce the BOARD_USES_PVMFWIMAGE variable, similarly to all other partitions, and use it where appropriate (in particular, where the soon-to-be incorrect assumption that pvmfw.img could only be a pre-built board image was made). Bug: 199717422 Test: m ${ANDROID_PRODUCT_OUT}/pvmfw.img # with TARGET_PKVM_ENABLED=true Change-Id: I8f4faa78c741d29b473303b521834387dbd48cd1 --- core/Makefile | 8 ++++---- core/board_config.mk | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/Makefile b/core/Makefile index c51babb7b1..caca06510b 100644 --- a/core/Makefile +++ b/core/Makefile @@ -3477,7 +3477,7 @@ endif # BOARD_PREBUILT_DTBOIMAGE # ----------------------------------------------------------------- # Protected VM firmware image -ifdef BOARD_PREBUILT_PVMFWIMAGE +ifeq ($(BOARD_USES_PVMFWIMAGE),true) INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img ifeq ($(BOARD_AVB_ENABLE),true) @@ -3493,7 +3493,7 @@ $(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE) cp $(BOARD_PREBUILT_PVMFWIMAGE) $@ endif -endif # BOARD_PREBUILT_PVMFWIMAGE +endif # BOARD_USES_PVMFWIMAGE # Returns a list of image targets corresponding to the given list of partitions. For example, it # returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET) @@ -4668,7 +4668,7 @@ ifdef BOARD_AVB_DTBO_KEY_PATH endif # BOARD_AVB_DTBO_KEY_PATH endif # BOARD_AVB_ENABLE endif # BOARD_PREBUILT_DTBOIMAGE -ifdef BOARD_PREBUILT_PVMFWIMAGE +ifeq ($(BOARD_USES_PVMFWIMAGE),true) $(hide) echo "has_pvmfw=true" >> $@ ifeq ($(BOARD_AVB_ENABLE),true) $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMG_PARTITION_SIZE)" >> $@ @@ -4679,7 +4679,7 @@ ifdef BOARD_AVB_PVMFW_KEY_PATH $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@ endif # BOARD_AVB_PVMFW_KEY_PATH endif # BOARD_AVB_ENABLE -endif # BOARD_PREBUILT_PVMFWIMAGE +endif # BOARD_USES_PVMFWIMAGE $(call dump-dynamic-partitions-info,$@) @# VINTF checks ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true) diff --git a/core/board_config.mk b/core/board_config.mk index 53dbb92c19..56c3e7125c 100644 --- a/core/board_config.mk +++ b/core/board_config.mk @@ -695,6 +695,12 @@ ifdef BOARD_PREBUILT_ODM_DLKMIMAGE endif .KATI_READONLY := BUILDING_ODM_DLKM_IMAGE +BOARD_USES_PVMFWIMAGE := +ifdef BOARD_PREBUILT_PVMFWIMAGE + BOARD_USES_PVMFWIMAGE := true +endif +.KATI_READONLY := BOARD_USES_PVMFWIMAGE + ########################################### # Ensure consistency among TARGET_RECOVERY_UPDATER_LIBS, AB_OTA_UPDATER, and PRODUCT_OTA_FORCE_NON_AB_PACKAGE. TARGET_RECOVERY_UPDATER_LIBS ?= From fa8193c0e9e3bb3f22a2078744eb95182ebcfd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Fri, 24 Sep 2021 15:49:00 +0200 Subject: [PATCH 2/3] Add framework for building the pvmfw.img partition Adapt the variables necessary for building pvmfw.img by following what was done for other Android partitions and introducing: - PRODUCT_BUILD_PVMFW_IMAGE - BUILDING_PVMFW_IMAGE - BUILT_PVMFWIMAGE_TARGET Replace the manual 'cp' by the more common 'copy-one-file'. Bug: 199831815 Test: m ${ANDROID_PRODUCT_OUT}/pvmfw.img # with TARGET_PKVM_ENABLED=true Change-Id: I5e4bbcbdbf4b96281ee54631938f097e9744883c --- core/Makefile | 11 +++++++---- core/board_config.mk | 12 ++++++++++++ core/product.mk | 1 + core/product_config.mk | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/Makefile b/core/Makefile index caca06510b..8b3c9eb60d 100644 --- a/core/Makefile +++ b/core/Makefile @@ -3480,17 +3480,20 @@ endif # BOARD_PREBUILT_DTBOIMAGE ifeq ($(BOARD_USES_PVMFWIMAGE),true) INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img +ifdef BOARD_PREBUILT_PVMFWIMAGE +BUILT_PVMFWIMAGE_TARGET := $(BOARD_PREBUILT_PVMFWIMAGE) +endif + ifeq ($(BOARD_AVB_ENABLE),true) -$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH) - cp $(BOARD_PREBUILT_PVMFWIMAGE) $@ +$(INSTALLED_PVMFWIMAGE_TARGET): $(BUILT_PVMFWIMAGE_TARGET) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH) + cp $(BUILT_PVMFWIMAGE_TARGET) $@ $(AVBTOOL) add_hash_footer \ --image $@ \ --partition_size $(BOARD_PVMFWIMG_PARTITION_SIZE) \ --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \ $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS) else -$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE) - cp $(BOARD_PREBUILT_PVMFWIMAGE) $@ +$(eval $(call copy-one-file,$(BUILT_PVMFWIMAGE_TARGET),$(INSTALLED_PVMFWIMAGE_TARGET))) endif endif # BOARD_USES_PVMFWIMAGE diff --git a/core/board_config.mk b/core/board_config.mk index 56c3e7125c..9c6b5cb500 100644 --- a/core/board_config.mk +++ b/core/board_config.mk @@ -699,8 +699,20 @@ BOARD_USES_PVMFWIMAGE := ifdef BOARD_PREBUILT_PVMFWIMAGE BOARD_USES_PVMFWIMAGE := true endif +ifeq ($(PRODUCT_BUILD_PVMFW_IMAGE),true) + BOARD_USES_PVMFWIMAGE := true +endif .KATI_READONLY := BOARD_USES_PVMFWIMAGE +BUILDING_PVMFW_IMAGE := +ifeq ($(PRODUCT_BUILD_PVMFW_IMAGE),true) + BUILDING_PVMFW_IMAGE := true +endif +ifdef BOARD_PREBUILT_PVMFWIMAGE + BUILDING_PVMFW_IMAGE := +endif +.KATI_READONLY := BUILDING_PVMFW_IMAGE + ########################################### # Ensure consistency among TARGET_RECOVERY_UPDATER_LIBS, AB_OTA_UPDATER, and PRODUCT_OTA_FORCE_NON_AB_PACKAGE. TARGET_RECOVERY_UPDATER_LIBS ?= diff --git a/core/product.mk b/core/product.mk index 9aaf5eb300..cac35f2fdb 100644 --- a/core/product.mk +++ b/core/product.mk @@ -389,6 +389,7 @@ _product_single_value_vars += PRODUCT_BUILD_BOOT_IMAGE _product_single_value_vars += PRODUCT_BUILD_VENDOR_BOOT_IMAGE _product_single_value_vars += PRODUCT_BUILD_VBMETA_IMAGE _product_single_value_vars += PRODUCT_BUILD_SUPER_EMPTY_IMAGE +_product_single_value_vars += PRODUCT_BUILD_PVMFW_IMAGE # List of boot jars delivered via updatable APEXes, following the same format as # PRODUCT_BOOT_JARS. diff --git a/core/product_config.mk b/core/product_config.mk index 54fbb7d121..c6471b9895 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -511,6 +511,7 @@ endef # Copy and check the value of each PRODUCT_BUILD_*_IMAGE variable $(foreach image, \ + PVMFW \ SYSTEM \ SYSTEM_OTHER \ VENDOR \ From 3bda0d6992b52ec1d5b1395a1b252e561df55b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Tue, 21 Sep 2021 13:49:35 +0200 Subject: [PATCH 3/3] Add generic board-agnostic pre-built pvmfw.img Make use of the pvmfw.img-building AOSP framework to provide a common default image instead of requiring boards to necessarily provide their own but allow over-writing it through BOARD_PREBUILT_PVMFWIMAGE, if desired. Note: The Android Virtualization Framework requires the pvmfw partition. Bug: 199717422 Test: m ${ANDROID_PRODUCT_OUT}/pvmfw.img Change-Id: I5e06f08d6e22178e45254b7ab63acd3855d99a38 --- core/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/Makefile b/core/Makefile index 8b3c9eb60d..3e116794d9 100644 --- a/core/Makefile +++ b/core/Makefile @@ -3479,9 +3479,12 @@ endif # BOARD_PREBUILT_DTBOIMAGE # Protected VM firmware image ifeq ($(BOARD_USES_PVMFWIMAGE),true) INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img +INTERNAL_PREBUILT_PVMFWIMAGE := packages/modules/Virtualization/pvmfw/pvmfw.img ifdef BOARD_PREBUILT_PVMFWIMAGE BUILT_PVMFWIMAGE_TARGET := $(BOARD_PREBUILT_PVMFWIMAGE) +else ifeq ($(BUILDING_PVMFW_IMAGE),true) +BUILT_PVMFWIMAGE_TARGET := $(INTERNAL_PREBUILT_PVMFWIMAGE) endif ifeq ($(BOARD_AVB_ENABLE),true)