Snap for 11933108 from 669b502042f169223765c7c835ccd9bf1ff3561a to sdk-release
Change-Id: I45b56440f3167c4f47324224d762e821daa9aa0f
diff --git a/project/hafnium/sp_layout.json b/project/hafnium/sp_layout.json
new file mode 100644
index 0000000..d291644
--- /dev/null
+++ b/project/hafnium/sp_layout.json
@@ -0,0 +1,7 @@
+{
+ "trusty" : {
+ "image": "lk.bin",
+ "pm": "trusty.dts",
+ "owner": "Plat"
+ }
+}
diff --git a/project/hafnium/tb_fw_config.dts b/project/hafnium/tb_fw_config.dts
new file mode 100644
index 0000000..85d8196
--- /dev/null
+++ b/project/hafnium/tb_fw_config.dts
@@ -0,0 +1,17 @@
+/dts-v1/;
+
+/ {
+ tb_fw-config {
+ compatible = "arm,tb_fw";
+ /* Disable authentication for development */
+ disable_auth = <0x0>;
+ };
+ secure-partitions {
+ compatible = "arm,sp";
+ trusty {
+ uuid = "40ee25f0-a2bc-304c-8c4c-a173c57d8af1";
+ load-address = <0x10000000>;
+ owner = "Plat";
+ };
+ };
+};
diff --git a/project/hafnium/tos_fw_config.dts b/project/hafnium/tos_fw_config.dts
new file mode 100644
index 0000000..94311fa
--- /dev/null
+++ b/project/hafnium/tos_fw_config.dts
@@ -0,0 +1,71 @@
+/dts-v1/;
+
+/ {
+ #size-cells = <0x2>;
+ #address-cells = <0x2>;
+ compatible = "arm,ffa-core-manifest-1.0";
+ attribute {
+ spmc_id = <0x8000>;
+ maj_ver = <0x1>;
+ min_ver = <0x1>;
+ exec_state = <0x0>;
+ /* i'm not sure this is right, or whether it does anything
+ the docs say that it's only used to verify that the entry
+ point is in range */
+ load_address = <0x0 0x0e200000>;
+ entrypoint = <0x0 0x0e200000>;
+ binary_size = <0x60000>;
+ };
+ cpus {
+ #address-cells = <0x1>;
+ #size-cells = <0x0>;
+ cpu@0 {
+ phandle = <0x8004>;
+ reg = <0x0>;
+ compatible = "arm,cortex-a57";
+ device_type = "cpu";
+ };
+ /*
+ * SPMC (Hafnium) requires secondary core nodes are declared
+ * in descending order.
+ */
+ cpu@3 {
+ phandle = <0x8001>;
+ reg = <0x3>;
+ compatible = "arm,cortex-a57";
+ device_type = "cpu";
+ };
+ cpu@2 {
+ phandle = <0x8002>;
+ reg = <0x2>;
+ compatible = "arm,cortex-a57";
+ device_type = "cpu";
+ };
+ cpu@1 {
+ phandle = <0x8003>;
+ reg = <0x1>;
+ compatible = "arm,cortex-a57";
+ device_type = "cpu";
+ };
+ };
+ secram@e000000 {
+ secure-status = "okay";
+ status = "disabled";
+ reg = <0x0 0xe000000 0x0 0x30000000>;
+ device_type = "memory";
+ };
+ ns-memory@40000000 {
+ reg = <0x0 0x40000000 0x0 0x40000000>;
+ device_type = "ns-memory";
+ };
+ hypervisor {
+ compatible = "hafnium,hafnium";
+ vm1 {
+ is_ffa_partition;
+ debug_name = "trusty";
+ load_address = <0x10000000>;
+ vcpu_count = <4>;
+ mem_size = <0x08000000>;
+ };
+ };
+};
diff --git a/project/hafnium/trusty.dts b/project/hafnium/trusty.dts
new file mode 100644
index 0000000..f0b144b
--- /dev/null
+++ b/project/hafnium/trusty.dts
@@ -0,0 +1,29 @@
+/dts-v1/;
+
+/ {
+ compatible = "arm,ffa-manifest-1.0";
+ ffa-version = <0x00010001>; /* 31:16 - Major, 15:0 - Minor */
+ uuid = <0xf025ee40 0x4c30bca2 0x73a14c8c 0xf18a7dc5>;
+ id = <1>;
+ auxiliary-id = <0xaf>;
+ description = "Trusty";
+
+ execution-ctx-count = <4>;
+ exception-level = <2>; /* S-EL1 */
+ execution-state = <0>; /* AARCH64 */
+ load-address = <0x10000000>;
+ entrypoint-offset = <0x00004000>;
+ xlat-granule = <0>; /* 4KiB */
+
+ messaging-method = <7>; /* Direct and indirect messages */
+ notification-support; /* Support receipt of notifications. */
+
+ ns-interrupts-action = <1>; /* Managed exit is supported */
+
+ boot-order = <0>;
+ gp-register-num = <0>; /* Place boot data into x0 */
+ boot-info {
+ compatible = "arm,ffa-manifest-boot-info";
+ ffa_manifest;
+ };
+};
diff --git a/project/qemu-atf-inc.mk b/project/qemu-atf-inc.mk
index a795153..03a8fa9 100644
--- a/project/qemu-atf-inc.mk
+++ b/project/qemu-atf-inc.mk
@@ -44,8 +44,26 @@
ATF_WITH_TRUSTY_GENERIC_SERVICES ?= false
+ifeq (true,$(call TOBOOL,$(HAFNIUM)))
+ATF_MAKE_ARGS := SPD=spmd
+ATF_MAKE_ARGS += SPMD_SPM_AT_SEL2=1
+ATF_MAKE_ARGS += BL32=$(BL32_BIN)
+ATF_MAKE_ARGS += BL33=$(TEST_RUNNER_BIN)
+ATF_MAKE_ARGS += SP_LAYOUT_FILE=$(HAFNIUM_OUT_DIR)/sp_layout.json
+ATF_MAKE_ARGS += QEMU_TOS_FW_CONFIG_DTS=$(HAFNIUM_OUT_DIR)/tos_fw_config.dts
+ATF_MAKE_ARGS += QEMU_TB_FW_CONFIG_DTS=$(HAFNIUM_OUT_DIR)/tb_fw_config.dts
+# Symlink the Hafnium DTBs to where ATF will look for them.
+HAFNIUM_DTBS := tb_fw_config.dtb tos_fw_config.dtb
+HAFNIUM_DTBS_SRCS := $(addprefix $(ATF_OUT_DIR)/fdts/, $(HAFNIUM_DTBS))
+$(HAFNIUM_DTBS_SRCS): $(ATF_BIN)
+HAFNIUM_DTBS_OUT := $(addprefix $(ATF_OUT_DIR)/, $(HAFNIUM_DTBS))
+$(HAFNIUM_DTBS_OUT): $(ATF_OUT_DIR)/%.dtb: $(ATF_OUT_DIR)/fdts/%.dtb
+ ln -sf $< $@
+EXTRA_BUILDDEPS += $(HAFNIUM_DTBS_OUT)
+else
ATF_MAKE_ARGS := SPD=trusty
ATF_MAKE_ARGS += SPMD_SPM_AT_SEL2=0
+endif
ATF_MAKE_ARGS += CC=$(CLANG_BINDIR)/clang
ATF_MAKE_ARGS += CROSS_COMPILE=$(ATF_TOOLCHAIN_PREFIX)
ATF_MAKE_ARGS += PLAT=$(ATF_PLAT)
@@ -64,7 +82,7 @@
$(ATF_BIN): ATF_ROOT:=$(ATF_ROOT)
$(ATF_BIN): ATF_MAKE_ARGS:=$(ATF_MAKE_ARGS)
$(ATF_BIN): .PHONY
- $(MAKE) -C $(ATF_ROOT) $(ATF_MAKE_ARGS)
+ $(MAKE) -C $(ATF_ROOT) $(ATF_MAKE_ARGS) all sp
# Add ATF_BIN to the list of project dependencies
EXTRA_BUILDDEPS += $(ATF_BIN)
diff --git a/project/qemu-generic-arm64-gicv3-hafnium-test-debug.mk b/project/qemu-generic-arm64-gicv3-hafnium-test-debug.mk
new file mode 100644
index 0000000..225dbf9
--- /dev/null
+++ b/project/qemu-generic-arm64-gicv3-hafnium-test-debug.mk
@@ -0,0 +1,24 @@
+# Copyright (C) 2024 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+QEMU_TRUSTY_PROJECT := generic-arm64-gicv3-test-debug
+
+# D-cache lines are 64 bytes on QEMU arm64
+GLOBAL_DEFINES += CACHE_LINE=64
+
+HAFNIUM := 1
+TIMER_ARM_GENERIC_SELECTED := CNTV
+
+include project/qemu-inc.mk
diff --git a/project/qemu-inc.mk b/project/qemu-inc.mk
index 060b2f2..f7f5b1a 100644
--- a/project/qemu-inc.mk
+++ b/project/qemu-inc.mk
@@ -79,6 +79,25 @@
APPLOADER_ENCRYPT_KEY_0_FILE := \
$(PROJECT_KEYS_DIR)/apploader_encrypt_test_key_0.bin
+LK_BIN := $(BUILDDIR)/lk.bin
+
+EXTRA_BUILDRULES += external/trusty/bootloader/test-runner/test-runner-inc.mk
+TEST_RUNNER_BIN := $(BUILDDIR)/test-runner/external/trusty/bootloader/test-runner/test-runner.bin
+
+ifeq (true,$(call TOBOOL,$(HAFNIUM)))
+HAFNIUM_OUT_DIR := $(BUILDDIR)/hafnium
+HAFNIUM_PREBUILTS := trusty/prebuilts/aosp/hafnium
+HAFNIUM_MANIFESTS := trusty/device/arm/generic-arm64/project/hafnium
+$(HAFNIUM_OUT_DIR)/%: $(HAFNIUM_PREBUILTS) $(HAFNIUM_MANIFESTS)
+ mkdir -p $(HAFNIUM_OUT_DIR)
+ cp -r $(HAFNIUM_PREBUILTS)/* $(HAFNIUM_OUT_DIR)
+ cp -r $(HAFNIUM_MANIFESTS)/* $(HAFNIUM_OUT_DIR)
+ ln -sf $(LK_BIN) $(HAFNIUM_OUT_DIR)/lk.bin
+BL32_BIN := $(HAFNIUM_OUT_DIR)/hafnium.bin
+else
+BL32_BIN := $(LK_BIN)
+endif
+
ATF_DEBUG := 1
ATF_PLAT := qemu
ATF_WITH_TRUSTY_GENERIC_SERVICES := true
@@ -96,9 +115,6 @@
LINUX_ARCH ?= arm64
include project/linux-inc.mk
-EXTRA_BUILDRULES += external/trusty/bootloader/test-runner/test-runner-inc.mk
-TEST_RUNNER_BIN := $(BUILDDIR)/test-runner/external/trusty/bootloader/test-runner/test-runner.bin
-
RUN_QEMU_SCRIPT := $(BUILDDIR)/run-qemu
RUN_SCRIPT := $(BUILDDIR)/run
STOP_SCRIPT := $(BUILDDIR)/stop
@@ -119,7 +135,7 @@
$(ATF_OUT_DIR)/bl32.bin \
$(ATF_OUT_DIR)/bl33.bin \
-$(ATF_OUT_DIR)/bl32.bin: $(BUILDDIR)/lk.bin $(ATF_OUT_DIR)
+$(ATF_OUT_DIR)/bl32.bin: $(BL32_BIN) $(ATF_OUT_DIR)
ln -sf $(abspath $<) $@
$(ATF_OUT_DIR)/bl33.bin: $(TEST_RUNNER_BIN) $(ATF_OUT_DIR)