Convert storage related UUIDs to GUID octet order
For better compatibility with UEFI components, this commit
converts the octet representation of UUIDs used for disk
and partition identification to the little-endian representation
instead of the standard big-endian representation.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I5281e465a9336fcf64e4e1639c320f4e3e8e33d0
diff --git a/components/media/volume/block_io_dev/test/block_io_dev_tests.cpp b/components/media/volume/block_io_dev/test/block_io_dev_tests.cpp
index f6ae2c4..33940c9 100644
--- a/components/media/volume/block_io_dev/test/block_io_dev_tests.cpp
+++ b/components/media/volume/block_io_dev/test/block_io_dev_tests.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -18,8 +18,8 @@
{
void setup()
{
- uuid_parse_to_octets("6152f22b-8128-4c1f-981f-3bd279519907",
- m_partition_guid.octets, sizeof(m_partition_guid.octets));
+ uuid_guid_octets_from_canonical(&m_partition_guid,
+ "6152f22b-8128-4c1f-981f-3bd279519907");
m_block_store = ram_block_store_init(&m_ram_block_store,
&m_partition_guid, NUM_BLOCKS, BLOCK_SIZE);
diff --git a/components/service/block_storage/block_store/device/ram/test/ram_block_store_tests.cpp b/components/service/block_storage/block_store/device/ram/test/ram_block_store_tests.cpp
index dd3e4fc..f7ba5b0 100644
--- a/components/service/block_storage/block_store/device/ram/test/ram_block_store_tests.cpp
+++ b/components/service/block_storage/block_store/device/ram/test/ram_block_store_tests.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -14,8 +14,8 @@
{
void setup()
{
- uuid_parse_to_octets("6152f22b-8128-4c1f-981f-3bd279519907",
- m_partition_guid.octets, sizeof(m_partition_guid.octets));
+ uuid_guid_octets_from_canonical(&m_partition_guid,
+ "6152f22b-8128-4c1f-981f-3bd279519907");
m_block_store = ram_block_store_init(&m_ram_block_store,
&m_partition_guid, NUM_BLOCKS, BLOCK_SIZE);
diff --git a/components/service/block_storage/block_store/device/semihosting/test/sh_block_store_tests.c b/components/service/block_storage/block_store/device/semihosting/test/sh_block_store_tests.c
index e21a8c6..3e76a39 100644
--- a/components/service/block_storage/block_store/device/semihosting/test/sh_block_store_tests.c
+++ b/components/service/block_storage/block_store/device/semihosting/test/sh_block_store_tests.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -36,9 +36,8 @@
}
struct uuid_octets disk_guid;
- uuid_parse_to_octets("418edc38-fa66-4871-979b-e67bee88b8f2",
- disk_guid.octets,
- sizeof(disk_guid.octets));
+ uuid_guid_octets_from_canonical(&disk_guid,
+ "418edc38-fa66-4871-979b-e67bee88b8f2");
semihosting_block_store_configure(&sh_block_store,
&disk_guid,
diff --git a/components/service/block_storage/block_store/partitioned/test/partitioned_block_store_tests.cpp b/components/service/block_storage/block_store/partitioned/test/partitioned_block_store_tests.cpp
index efce19e..a499b95 100644
--- a/components/service/block_storage/block_store/partitioned/test/partitioned_block_store_tests.cpp
+++ b/components/service/block_storage/block_store/partitioned/test/partitioned_block_store_tests.cpp
@@ -37,8 +37,8 @@
CHECK_TRUE(back_store);
/* Configure partition 1 */
- uuid_parse_to_octets("18ae7d62-0974-4dd3-8d2e-e9c166554165",
- m_partition_1_guid.octets, sizeof(m_partition_1_guid.octets));
+ uuid_guid_octets_from_canonical(&m_partition_1_guid,
+ "18ae7d62-0974-4dd3-8d2e-e9c166554165");
CHECK_TRUE(partitioned_block_store_add_partition(
&m_partitioned_store,
@@ -48,8 +48,8 @@
0, NULL));
/* Configure partition 2 */
- uuid_parse_to_octets("7924fda7-4666-41d7-887a-91a913712b93",
- m_partition_2_guid.octets, sizeof(m_partition_2_guid.octets));
+ uuid_guid_octets_from_canonical(&m_partition_2_guid,
+ "7924fda7-4666-41d7-887a-91a913712b93");
CHECK_TRUE(partitioned_block_store_add_partition(
&m_partitioned_store,
diff --git a/components/service/block_storage/config/gpt/gpt_partition_configurator.c b/components/service/block_storage/config/gpt/gpt_partition_configurator.c
index ccc5496..076c65f 100644
--- a/components/service/block_storage/config/gpt/gpt_partition_configurator.c
+++ b/components/service/block_storage/config/gpt/gpt_partition_configurator.c
@@ -20,13 +20,9 @@
*/
bool is_configured = false;
const partition_entry_t *partition_entry = NULL;
- uuid_t uuid;
-
- /* Convert to tf-a uuid encoding */
- uuid_reverse_octets(partition_guid, (uint8_t*)&uuid, sizeof(uuid));
/* Check if matching partition entry exists in loaded GPT */
- partition_entry = get_partition_entry_by_uuid(&uuid);
+ partition_entry = get_partition_entry_by_uuid((uuid_t *)partition_guid->octets);
if (partition_entry &&
back_store_info->block_size &&
diff --git a/components/service/block_storage/config/ref/ref_partition_configurator.c b/components/service/block_storage/config/ref/ref_partition_configurator.c
index c880afd..cf6dc86 100644
--- a/components/service/block_storage/config/ref/ref_partition_configurator.c
+++ b/components/service/block_storage/config/ref/ref_partition_configurator.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -13,9 +13,7 @@
{
struct uuid_octets guid;
- size_t parsed_uuid_len =
- uuid_parse_to_octets(REF_PARTITION_1_GUID, guid.octets, sizeof(guid.octets));
- assert(parsed_uuid_len);
+ uuid_guid_octets_from_canonical(&guid, REF_PARTITION_1_GUID);
bool is_success = partitioned_block_store_add_partition(
subject,
&guid,
@@ -26,9 +24,7 @@
if (!is_success)
return false;
- parsed_uuid_len =
- uuid_parse_to_octets(REF_PARTITION_2_GUID, guid.octets, sizeof(guid.octets));
- assert(parsed_uuid_len);
+ uuid_guid_octets_from_canonical(&guid, REF_PARTITION_2_GUID);
is_success = partitioned_block_store_add_partition(
subject,
&guid,
@@ -39,9 +35,7 @@
if (!is_success)
return false;
- parsed_uuid_len =
- uuid_parse_to_octets(REF_PARTITION_3_GUID, guid.octets, sizeof(guid.octets));
- assert(parsed_uuid_len);
+ uuid_guid_octets_from_canonical(&guid, REF_PARTITION_3_GUID);
is_success = partitioned_block_store_add_partition(
subject,
&guid,
@@ -52,9 +46,7 @@
if (!is_success)
return false;
- parsed_uuid_len =
- uuid_parse_to_octets(REF_PARTITION_4_GUID, guid.octets, sizeof(guid.octets));
- assert(parsed_uuid_len);
+ uuid_guid_octets_from_canonical(&guid, REF_PARTITION_4_GUID);
is_success = partitioned_block_store_add_partition(
subject,
&guid,
diff --git a/components/service/block_storage/test/service/block_storage_service_tests.cpp b/components/service/block_storage/test/service/block_storage_service_tests.cpp
index 00521b9..3c376d9 100644
--- a/components/service/block_storage/test/service/block_storage_service_tests.cpp
+++ b/components/service/block_storage/test/service/block_storage_service_tests.cpp
@@ -28,14 +28,14 @@
CHECK_TRUE(m_block_store);
- uuid_parse_to_octets(REF_PARTITION_1_GUID,
- m_partition_1_guid.octets, sizeof(m_partition_1_guid.octets));
- uuid_parse_to_octets(REF_PARTITION_2_GUID,
- m_partition_2_guid.octets, sizeof(m_partition_2_guid.octets));
- uuid_parse_to_octets(REF_PARTITION_3_GUID,
- m_partition_3_guid.octets, sizeof(m_partition_3_guid.octets));
- uuid_parse_to_octets(REF_PARTITION_4_GUID,
- m_partition_4_guid.octets, sizeof(m_partition_4_guid.octets));
+ uuid_guid_octets_from_canonical(&m_partition_1_guid,
+ REF_PARTITION_1_GUID);
+ uuid_guid_octets_from_canonical(&m_partition_2_guid,
+ REF_PARTITION_2_GUID);
+ uuid_guid_octets_from_canonical(&m_partition_3_guid,
+ REF_PARTITION_3_GUID);
+ uuid_guid_octets_from_canonical(&m_partition_4_guid,
+ REF_PARTITION_4_GUID);
}
void teardown()
diff --git a/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp b/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp
index 7e74a01..56e87c8 100644
--- a/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp
+++ b/components/service/locator/standalone/services/protected-storage/ps_service_context.cpp
@@ -28,7 +28,8 @@
struct uuid_octets guid;
const struct sfs_flash_info_t *flash_info = NULL;
- uuid_parse_to_octets(DISK_GUID_UNIQUE_PARTITION_PSA_PS, guid.octets, sizeof(guid.octets));
+ uuid_guid_octets_from_canonical(&guid,
+ DISK_GUID_UNIQUE_PARTITION_PSA_PS);
m_block_store = client_block_store_factory_create(
"sn:trustedfirmware.org:block-storage:0");
diff --git a/components/service/secure_storage/backend/secure_flash_store/test/sfs_block_store_tests.cpp b/components/service/secure_storage/backend/secure_flash_store/test/sfs_block_store_tests.cpp
index 64fb952..226f92a 100644
--- a/components/service/secure_storage/backend/secure_flash_store/test/sfs_block_store_tests.cpp
+++ b/components/service/secure_storage/backend/secure_flash_store/test/sfs_block_store_tests.cpp
@@ -24,7 +24,7 @@
struct uuid_octets guid;
const struct sfs_flash_info_t *flash_info = NULL;
- uuid_parse_to_octets(REF_PARTITION_2_GUID, guid.octets, sizeof(guid.octets));
+ uuid_guid_octets_from_canonical(&guid, REF_PARTITION_2_GUID);
block_store = ref_ram_block_store_factory_create();
CHECK_TRUE(block_store);
diff --git a/components/service/secure_storage/factory/sp/sfs_shared_block_store/storage_factory.c b/components/service/secure_storage/factory/sp/sfs_shared_block_store/storage_factory.c
index 44bc38b..36e606d 100644
--- a/components/service/secure_storage/factory/sp/sfs_shared_block_store/storage_factory.c
+++ b/components/service/secure_storage/factory/sp/sfs_shared_block_store/storage_factory.c
@@ -66,11 +66,9 @@
const struct sfs_flash_info_t *flash_info = NULL;
if (security_class == storage_factory_security_class_INTERNAL_TRUSTED)
- uuid_parse_to_octets(
- DISK_GUID_UNIQUE_PARTITION_PSA_ITS, guid.octets, sizeof(guid.octets));
+ uuid_guid_octets_from_canonical(&guid, DISK_GUID_UNIQUE_PARTITION_PSA_ITS);
else
- uuid_parse_to_octets(
- DISK_GUID_UNIQUE_PARTITION_PSA_PS, guid.octets, sizeof(guid.octets));
+ uuid_guid_octets_from_canonical(&guid, DISK_GUID_UNIQUE_PARTITION_PSA_PS);
psa_status_t status = sfs_flash_block_store_adapter_init(
&storage_instance.sfs_flash_adapter,