VHE: Refactor sp_manifest to partition manifest
This patch renames struct sp_manifest to partition_manifest and struct
manifest_vm.sp to partition. ff-a partitions are not necessarily secure
partitions always so partition is more appropriate than using the term
sp.
Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
Change-Id: I745db3f19a73488a5cf522cf9141989f5483e76a
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index bdf0cb3..0cf6eb4 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -106,7 +106,7 @@
/**
* Partition manifest as described in PSA FF-A v1.0 spec section 3.1
*/
-struct sp_manifest {
+struct partition_manifest {
/** PSA-FF-A expected version - mandatory */
uint32_t ffa_version;
/** UUID - mandatory */
@@ -182,7 +182,7 @@
struct string kernel_filename;
struct smc_whitelist smc_whitelist;
bool is_ffa_partition;
- struct sp_manifest sp;
+ struct partition_manifest partition;
union {
/* Properties specific to the primary VM. */
diff --git a/src/arch/aarch64/arm_smmuv3/arm_smmuv3.c b/src/arch/aarch64/arm_smmuv3/arm_smmuv3.c
index 6beadc5..8cbfc2a 100644
--- a/src/arch/aarch64/arm_smmuv3/arm_smmuv3.c
+++ b/src/arch/aarch64/arm_smmuv3/arm_smmuv3.c
@@ -1388,8 +1388,8 @@
struct device_region upstream_peripheral;
/* Iterate through device region nodes described in vm manifest */
- for (i = 0; i < manifest_vm->sp.dev_region_count; i++) {
- upstream_peripheral = manifest_vm->sp.dev_regions[i];
+ for (i = 0; i < manifest_vm->partition.dev_region_count; i++) {
+ upstream_peripheral = manifest_vm->partition.dev_regions[i];
if (upstream_peripheral.smmu_id != arm_smmuv3.smmu_id) {
dlog_warning(
diff --git a/src/load.c b/src/load.c
index 5501e12..d6825df 100644
--- a/src/load.c
+++ b/src/load.c
@@ -134,13 +134,13 @@
struct mpool *ppool)
{
vm_locked.vm->smc_whitelist = manifest_vm->smc_whitelist;
- vm_locked.vm->uuid = manifest_vm->sp.uuid;
+ vm_locked.vm->uuid = manifest_vm->partition.uuid;
if (manifest_vm->is_ffa_partition) {
/* Link rxtx buffers to mailbox */
- if (manifest_vm->sp.rxtx.available) {
+ if (manifest_vm->partition.rxtx.available) {
if (!link_rxtx_to_mailbox(stage1_locked, vm_locked,
- manifest_vm->sp.rxtx,
+ manifest_vm->partition.rxtx,
ppool)) {
dlog_error(
"Unable to Link RX/TX buffer with "
@@ -150,11 +150,13 @@
}
vm_locked.vm->messaging_method =
- manifest_vm->sp.messaging_method;
+ manifest_vm->partition.messaging_method;
- vm_locked.vm->managed_exit = manifest_vm->sp.managed_exit;
+ vm_locked.vm->managed_exit =
+ manifest_vm->partition.managed_exit;
- vm_locked.vm->boot_order = manifest_vm->sp.boot_order;
+ vm_locked.vm->boot_order = manifest_vm->partition.boot_order;
+
/* Updating boot list according to boot_order */
vm_update_boot(vm_locked.vm);
@@ -191,9 +193,9 @@
bool ret;
if (manifest_vm->is_ffa_partition) {
- primary_begin = pa_init(manifest_vm->sp.load_addr);
+ primary_begin = pa_init(manifest_vm->partition.load_addr);
primary_entry = ipa_add(ipa_from_pa(primary_begin),
- manifest_vm->sp.ep_offset);
+ manifest_vm->partition.ep_offset);
} else {
primary_begin =
(manifest_vm->primary.boot_address ==
@@ -206,7 +208,7 @@
paddr_t primary_end = pa_add(primary_begin, RSIZE_MAX);
/* Primary VM must be a VM */
- CHECK(manifest_vm->sp.run_time_el == EL1);
+ CHECK(manifest_vm->partition.run_time_el == EL1);
/*
* Load the kernel if a filename is specified in the VM manifest.
@@ -434,11 +436,11 @@
* An S-EL0 partition must contain only 1 vCPU (UP migratable) per the
* FF-A 1.0 spec.
*/
- CHECK(manifest_vm->sp.run_time_el != S_EL0 ||
+ CHECK(manifest_vm->partition.run_time_el != S_EL0 ||
manifest_vm->secondary.vcpu_count == 1);
if (!vm_init_next(manifest_vm->secondary.vcpu_count, ppool, &vm,
- (manifest_vm->sp.run_time_el == S_EL0))) {
+ (manifest_vm->partition.run_time_el == S_EL0))) {
dlog_error("Unable to initialise VM.\n");
return false;
}
@@ -471,8 +473,9 @@
size_t total_alloc = 0;
/* Map memory-regions */
- while (j < manifest_vm->sp.mem_region_count) {
- size = manifest_vm->sp.mem_regions[j].page_count *
+ while (j < manifest_vm->partition.mem_region_count) {
+ size = manifest_vm->partition.mem_regions[j]
+ .page_count *
PAGE_SIZE;
/*
* For memory-regions without base-address, memory
@@ -482,8 +485,8 @@
* TODO: Add mechanism to let partition know of these
* memory regions
*/
- if (manifest_vm->sp.mem_regions[j].base_address ==
- MANIFEST_INVALID_ADDRESS) {
+ if (manifest_vm->partition.mem_regions[j]
+ .base_address == MANIFEST_INVALID_ADDRESS) {
total_alloc += size;
/* Don't go beyond half the VM's memory space */
if (total_alloc >
@@ -499,7 +502,7 @@
region_begin = pa_subtract(alloc_base, size);
alloc_base = region_begin;
- map_mode = manifest_vm->sp.mem_regions[j]
+ map_mode = manifest_vm->partition.mem_regions[j]
.attributes;
if (vm->el0_partition) {
map_mode |= MM_MODE_USER | MM_MODE_NG;
@@ -523,12 +526,12 @@
* Identity map memory region for both case,
* VA(S-EL0) or IPA(S-EL1).
*/
- region_begin =
- pa_init(manifest_vm->sp.mem_regions[j]
- .base_address);
+ region_begin = pa_init(
+ manifest_vm->partition.mem_regions[j]
+ .base_address);
region_end = pa_add(region_begin, size);
- map_mode = manifest_vm->sp.mem_regions[j]
+ map_mode = manifest_vm->partition.mem_regions[j]
.attributes;
if (vm->el0_partition) {
map_mode |= MM_MODE_USER | MM_MODE_NG;
@@ -560,14 +563,17 @@
/* Map device-regions */
j = 0;
- while (j < manifest_vm->sp.dev_region_count) {
- region_begin = pa_init(
- manifest_vm->sp.dev_regions[j].base_address);
- size = manifest_vm->sp.dev_regions[j].page_count *
+ while (j < manifest_vm->partition.dev_region_count) {
+ region_begin =
+ pa_init(manifest_vm->partition.dev_regions[j]
+ .base_address);
+ size = manifest_vm->partition.dev_regions[j]
+ .page_count *
PAGE_SIZE;
region_end = pa_add(region_begin, size);
- map_mode = manifest_vm->sp.dev_regions[j].attributes;
+ map_mode = manifest_vm->partition.dev_regions[j]
+ .attributes;
if (vm->el0_partition) {
map_mode |= MM_MODE_USER | MM_MODE_NG;
}
@@ -593,8 +599,8 @@
j++;
}
- secondary_entry =
- ipa_add(secondary_entry, manifest_vm->sp.ep_offset);
+ secondary_entry = ipa_add(secondary_entry,
+ manifest_vm->partition.ep_offset);
}
/*
@@ -822,9 +828,9 @@
if (manifest_vm->is_ffa_partition) {
secondary_mem_begin =
- pa_init(manifest_vm->sp.load_addr);
- secondary_mem_end =
- pa_init(manifest_vm->sp.load_addr + mem_size);
+ pa_init(manifest_vm->partition.load_addr);
+ secondary_mem_end = pa_init(
+ manifest_vm->partition.load_addr + mem_size);
} else if (!carve_out_mem_range(mem_ranges_available,
params->mem_ranges_count,
mem_size, &secondary_mem_begin,
diff --git a/src/manifest.c b/src/manifest.c
index 1101081..fc02daa 100644
--- a/src/manifest.c
+++ b/src/manifest.c
@@ -344,7 +344,7 @@
&vm->primary.boot_address));
}
TRY(read_optional_uint8(node, "exception-level", (uint8_t)EL1,
- (uint8_t *)&vm->sp.run_time_el));
+ (uint8_t *)&vm->partition.run_time_el));
return MANIFEST_SUCCESS;
}
@@ -541,48 +541,50 @@
return MANIFEST_ERROR_NOT_COMPATIBLE;
}
- TRY(read_uint32(&root, "ffa-version", &vm->sp.ffa_version));
+ TRY(read_uint32(&root, "ffa-version", &vm->partition.ffa_version));
dlog_verbose(" Expected FF-A version %u.%u\n",
- vm->sp.ffa_version >> 16, vm->sp.ffa_version & 0xffff);
+ vm->partition.ffa_version >> 16,
+ vm->partition.ffa_version & 0xffff);
TRY(read_uint32list(&root, "uuid", &uuid));
while (uint32list_has_next(&uuid) && i < 4) {
TRY(uint32list_get_next(&uuid, &uuid_word));
- vm->sp.uuid.uuid[i] = uuid_word;
+ vm->partition.uuid.uuid[i] = uuid_word;
i++;
}
- dlog_verbose(" UUID %#x-%x-%x-%x\n", vm->sp.uuid.uuid[0],
- vm->sp.uuid.uuid[1], vm->sp.uuid.uuid[2],
- vm->sp.uuid.uuid[3]);
+ dlog_verbose(" UUID %#x-%x-%x-%x\n", vm->partition.uuid.uuid[0],
+ vm->partition.uuid.uuid[1], vm->partition.uuid.uuid[2],
+ vm->partition.uuid.uuid[3]);
TRY(read_uint16(&root, "execution-ctx-count",
- &vm->sp.execution_ctx_count));
+ &vm->partition.execution_ctx_count));
dlog_verbose(" Number of execution context %u\n",
- vm->sp.execution_ctx_count);
+ vm->partition.execution_ctx_count);
TRY(read_uint8(&root, "exception-level",
- (uint8_t *)&vm->sp.run_time_el));
- dlog_verbose(" Run-time EL %u\n", vm->sp.run_time_el);
+ (uint8_t *)&vm->partition.run_time_el));
+ dlog_verbose(" Run-time EL %u\n", vm->partition.run_time_el);
TRY(read_uint8(&root, "execution-state",
- (uint8_t *)&vm->sp.execution_state));
- dlog_verbose(" Execution state %u\n", vm->sp.execution_state);
+ (uint8_t *)&vm->partition.execution_state));
+ dlog_verbose(" Execution state %u\n", vm->partition.execution_state);
- TRY(read_optional_uint64(&root, "load-address", 0, &vm->sp.load_addr));
- dlog_verbose(" Load address %#x\n", vm->sp.load_addr);
+ TRY(read_optional_uint64(&root, "load-address", 0,
+ &vm->partition.load_addr));
+ dlog_verbose(" Load address %#x\n", vm->partition.load_addr);
TRY(read_optional_uint64(&root, "entrypoint-offset", 0,
- &vm->sp.ep_offset));
- dlog_verbose(" Entry point offset %#x\n", vm->sp.ep_offset);
+ &vm->partition.ep_offset));
+ dlog_verbose(" Entry point offset %#x\n", vm->partition.ep_offset);
TRY(read_optional_uint16(&root, "boot-order", DEFAULT_BOOT_ORDER,
- &vm->sp.boot_order));
- dlog_verbose(" Boot order %#u\n", vm->sp.boot_order);
+ &vm->partition.boot_order));
+ dlog_verbose(" Boot order %#u\n", vm->partition.boot_order);
TRY(read_optional_uint8(&root, "xlat-granule", 0,
- (uint8_t *)&vm->sp.xlat_granule));
- dlog_verbose(" Translation granule %u\n", vm->sp.xlat_granule);
+ (uint8_t *)&vm->partition.xlat_granule));
+ dlog_verbose(" Translation granule %u\n", vm->partition.xlat_granule);
ffa_node = root;
if (fdt_find_child(&ffa_node, &rxtx_node_name)) {
@@ -596,38 +598,39 @@
* while parsing memory regions.
*/
TRY(read_uint32(&ffa_node, "rx-buffer",
- &vm->sp.rxtx.rx_phandle));
+ &vm->partition.rxtx.rx_phandle));
TRY(read_uint32(&ffa_node, "tx-buffer",
- &vm->sp.rxtx.tx_phandle));
+ &vm->partition.rxtx.tx_phandle));
- vm->sp.rxtx.available = true;
+ vm->partition.rxtx.available = true;
}
TRY(read_uint8(&root, "messaging-method",
- (uint8_t *)&vm->sp.messaging_method));
- dlog_verbose(" Messaging method %u\n", vm->sp.messaging_method);
+ (uint8_t *)&vm->partition.messaging_method));
+ dlog_verbose(" Messaging method %u\n", vm->partition.messaging_method);
- TRY(read_bool(&root, "managed-exit", &vm->sp.managed_exit));
+ TRY(read_bool(&root, "managed-exit", &vm->partition.managed_exit));
/* Parse memory-regions */
ffa_node = root;
if (fdt_find_child(&ffa_node, &mem_region_node_name)) {
- TRY(parse_ffa_memory_region_node(&ffa_node, vm->sp.mem_regions,
- &vm->sp.mem_region_count,
- &vm->sp.rxtx));
+ TRY(parse_ffa_memory_region_node(
+ &ffa_node, vm->partition.mem_regions,
+ &vm->partition.mem_region_count, &vm->partition.rxtx));
}
dlog_verbose(" Total %u memory regions found\n",
- vm->sp.mem_region_count);
+ vm->partition.mem_region_count);
/* Parse Device-regions */
ffa_node = root;
if (fdt_find_child(&ffa_node, &dev_region_node_name)) {
- TRY(parse_ffa_device_region_node(&ffa_node, vm->sp.dev_regions,
- &vm->sp.dev_region_count));
+ TRY(parse_ffa_device_region_node(
+ &ffa_node, vm->partition.dev_regions,
+ &vm->partition.dev_region_count));
}
dlog_verbose(" Total %u device regions found\n",
- vm->sp.dev_region_count);
+ vm->partition.dev_region_count);
return MANIFEST_SUCCESS;
}
@@ -641,9 +644,9 @@
const char *error_string = "specified in manifest is unsupported";
/* ensure that the SPM version is compatible */
- ffa_version_major =
- (vm->sp.ffa_version & 0xffff0000) >> FFA_VERSION_MAJOR_OFFSET;
- ffa_version_minor = vm->sp.ffa_version & 0xffff;
+ ffa_version_major = (vm->partition.ffa_version & 0xffff0000) >>
+ FFA_VERSION_MAJOR_OFFSET;
+ ffa_version_minor = vm->partition.ffa_version & 0xffff;
if (ffa_version_major != FFA_VERSION_MAJOR ||
ffa_version_minor > FFA_VERSION_MINOR) {
@@ -652,39 +655,41 @@
ret_code = MANIFEST_ERROR_NOT_COMPATIBLE;
}
- if (vm->sp.xlat_granule != PAGE_4KB) {
+ if (vm->partition.xlat_granule != PAGE_4KB) {
dlog_error("Translation granule %s: %u\n", error_string,
- vm->sp.xlat_granule);
+ vm->partition.xlat_granule);
ret_code = MANIFEST_ERROR_NOT_COMPATIBLE;
}
- if (vm->sp.execution_state != AARCH64) {
+ if (vm->partition.execution_state != AARCH64) {
dlog_error("Execution state %s: %u\n", error_string,
- vm->sp.execution_state);
+ vm->partition.execution_state);
ret_code = MANIFEST_ERROR_NOT_COMPATIBLE;
}
- if (vm->sp.run_time_el != EL1 && vm->sp.run_time_el != S_EL1 &&
- vm->sp.run_time_el != S_EL0) {
+ if (vm->partition.run_time_el != EL1 &&
+ vm->partition.run_time_el != S_EL1 &&
+ vm->partition.run_time_el != S_EL0) {
dlog_error("Exception level %s: %d\n", error_string,
- vm->sp.run_time_el);
+ vm->partition.run_time_el);
ret_code = MANIFEST_ERROR_NOT_COMPATIBLE;
}
- if ((vm->sp.messaging_method &
+ if ((vm->partition.messaging_method &
~(FFA_PARTITION_DIRECT_REQ_RECV | FFA_PARTITION_DIRECT_REQ_SEND |
FFA_PARTITION_INDIRECT_MSG)) != 0U) {
dlog_error("Messaging method %s: %x\n", error_string,
- vm->sp.messaging_method);
+ vm->partition.messaging_method);
ret_code = MANIFEST_ERROR_NOT_COMPATIBLE;
}
- if (vm->sp.run_time_el == S_EL0 && vm->sp.execution_ctx_count != 1) {
+ if (vm->partition.run_time_el == S_EL0 &&
+ vm->partition.execution_ctx_count != 1) {
dlog_error(
"Exception level and execution context count %s: %d "
"%d\n",
- error_string, vm->sp.run_time_el,
- vm->sp.execution_ctx_count);
+ error_string, vm->partition.run_time_el,
+ vm->partition.execution_ctx_count);
ret_code = MANIFEST_ERROR_NOT_COMPATIBLE;
}
@@ -772,11 +777,11 @@
goto exit_unmap;
}
- if (vm->sp.load_addr != sp_pkg_addr) {
+ if (vm->partition.load_addr != sp_pkg_addr) {
dlog_warning(
"Partition's load address at its manifest differs"
" from specified in partition's package.\n");
- vm->sp.load_addr = sp_pkg_addr;
+ vm->partition.load_addr = sp_pkg_addr;
}
ret = sanity_check_ffa_manifest(vm);
diff --git a/src/manifest_test.cc b/src/manifest_test.cc
index 89d5de6..4588fb9 100644
--- a/src/manifest_test.cc
+++ b/src/manifest_test.cc
@@ -1047,39 +1047,41 @@
ASSERT_EQ(ffa_manifest_from_vec(&m, dtb), MANIFEST_SUCCESS);
- ASSERT_EQ(m.vm[0].sp.ffa_version, 0x10000);
+ ASSERT_EQ(m.vm[0].partition.ffa_version, 0x10000);
ASSERT_THAT(
- std::span(m.vm[0].sp.uuid.uuid, 4),
+ std::span(m.vm[0].partition.uuid.uuid, 4),
ElementsAre(0xb4b5671e, 0x4a904fe1, 0xb81ffb13, 0xdae1dacb));
- ASSERT_EQ(m.vm[0].sp.execution_ctx_count, 1);
- ASSERT_EQ(m.vm[0].sp.run_time_el, S_EL1);
- ASSERT_EQ(m.vm[0].sp.execution_state, AARCH64);
- ASSERT_EQ(m.vm[0].sp.ep_offset, 0x00001000);
- ASSERT_EQ(m.vm[0].sp.xlat_granule, PAGE_4KB);
- ASSERT_EQ(m.vm[0].sp.boot_order, 0);
- ASSERT_EQ(m.vm[0].sp.messaging_method, FFA_PARTITION_INDIRECT_MSG);
- ASSERT_EQ(m.vm[0].sp.managed_exit, true);
- ASSERT_EQ(m.vm[0].sp.mem_regions[0].base_address, 0x7100000);
- ASSERT_EQ(m.vm[0].sp.mem_regions[0].page_count, 4);
- ASSERT_EQ(m.vm[0].sp.mem_regions[0].attributes, 7);
- ASSERT_EQ(m.vm[0].sp.rxtx.available, true);
- ASSERT_EQ(m.vm[0].sp.rxtx.rx_buffer->base_address, 0x7300000);
- ASSERT_EQ(m.vm[0].sp.rxtx.rx_buffer->page_count, 1);
- ASSERT_EQ(m.vm[0].sp.rxtx.rx_buffer->attributes, 1);
- ASSERT_EQ(m.vm[0].sp.rxtx.tx_buffer->base_address, 0x7310000);
- ASSERT_EQ(m.vm[0].sp.rxtx.tx_buffer->page_count, 1);
- ASSERT_EQ(m.vm[0].sp.rxtx.tx_buffer->attributes, 3);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].base_address, 0x7200000);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].page_count, 16);
+ ASSERT_EQ(m.vm[0].partition.execution_ctx_count, 1);
+ ASSERT_EQ(m.vm[0].partition.run_time_el, S_EL1);
+ ASSERT_EQ(m.vm[0].partition.execution_state, AARCH64);
+ ASSERT_EQ(m.vm[0].partition.ep_offset, 0x00001000);
+ ASSERT_EQ(m.vm[0].partition.xlat_granule, PAGE_4KB);
+ ASSERT_EQ(m.vm[0].partition.boot_order, 0);
+ ASSERT_EQ(m.vm[0].partition.messaging_method,
+ FFA_PARTITION_INDIRECT_MSG);
+ ASSERT_EQ(m.vm[0].partition.managed_exit, true);
+ ASSERT_EQ(m.vm[0].partition.mem_regions[0].base_address, 0x7100000);
+ ASSERT_EQ(m.vm[0].partition.mem_regions[0].page_count, 4);
+ ASSERT_EQ(m.vm[0].partition.mem_regions[0].attributes, 7);
+ ASSERT_EQ(m.vm[0].partition.rxtx.available, true);
+ ASSERT_EQ(m.vm[0].partition.rxtx.rx_buffer->base_address, 0x7300000);
+ ASSERT_EQ(m.vm[0].partition.rxtx.rx_buffer->page_count, 1);
+ ASSERT_EQ(m.vm[0].partition.rxtx.rx_buffer->attributes, 1);
+ ASSERT_EQ(m.vm[0].partition.rxtx.tx_buffer->base_address, 0x7310000);
+ ASSERT_EQ(m.vm[0].partition.rxtx.tx_buffer->page_count, 1);
+ ASSERT_EQ(m.vm[0].partition.rxtx.tx_buffer->attributes, 3);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].base_address, 0x7200000);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].page_count, 16);
+
/* Attribute is ORed with MM_MODE_D */
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].attributes, (3 | 8));
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].smmu_id, 1);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].stream_ids[0], 0);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].stream_ids[1], 1);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].interrupts[0].id, 2);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].interrupts[0].attributes, 3);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].interrupts[1].id, 4);
- ASSERT_EQ(m.vm[0].sp.dev_regions[0].interrupts[1].attributes, 5);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].attributes, (3 | 8));
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].smmu_id, 1);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].stream_ids[0], 0);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].stream_ids[1], 1);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].interrupts[0].id, 2);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].interrupts[0].attributes, 3);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].interrupts[1].id, 4);
+ ASSERT_EQ(m.vm[0].partition.dev_regions[0].interrupts[1].attributes, 5);
}
} /* namespace */