feat(gpt): add test to corrupt gpt entries
Corrupt the GPT entries by adding entries parameter to corrupt_gpt_bin(),
which will empty the entries in LBA2 through LBA34. This will force
the use of backup gpt at the last LBA.
Add header parameter to corrupt_gpt_bin() for header option.
Signed-off-by: Lauren Wehrmeister <lauren.wehrmeister@arm.com>
Change-Id: Ie2ba6d9a081b7f705f7ee689e52bf23bfbb4e5dc
diff --git a/fvp_utils.sh b/fvp_utils.sh
index 8ee16d6..015a9b9 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -572,11 +572,37 @@
#corrupt GPT image header and archive it
corrupt_gpt_bin() {
bin="${1:?}"
+ corrupt_data=$2
- # Primary GPT header is present in LBA-1 second block after MBR
- # empty the primary GPT header forcing to use backup GPT header
- # and backup GPT entries.
- dd if=/dev/zero of=$bin bs=512 seek=1 count=1 conv=notrunc
+ # Check if parameters are provided
+ if [ -z "$bin" ] || [ -z "$corrupt_data" ]; then
+ echo "Usage: corrupt_gpt_bin <bin> <corrupt_data>"
+ return 1
+ fi
+
+ case "$corrupt_data" in
+ "header")
+ # Primary GPT header is present in LBA-1 second block after MBR
+ # empty the primary GPT header forcing to use backup GPT header
+ # and backup GPT entries.
+ seek=1
+ count=1
+ ;;
+ "partition-entries")
+ # GPT partition entry array is present in LBA-2 through LBA-34
+ # blocks empty the GPT partition entry array forcing to use backup
+ # GPT header and backup GPT entries.
+ seek=2
+ count=32
+ ;;
+ *)
+ echo "Invalid $corrupt_data. Use 'header', 'partition-entries'"
+ return 1
+ ;;
+ esac
+
+ # Use parameters in the dd command
+ dd if=/dev/zero of=$bin bs=512 seek=$seek count=$count conv=notrunc
}
set +u
diff --git a/group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.backup_gpt-aemv8a.gpt-debug b/group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.entries_backup_gpt-aemv8a.gpt-debug
similarity index 100%
rename from group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.backup_gpt-aemv8a.gpt-debug
rename to group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.entries_backup_gpt-aemv8a.gpt-debug
diff --git a/group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.backup_gpt-aemv8a.gpt-debug b/group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.header_backup_gpt-aemv8a.gpt-debug
similarity index 100%
copy from group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.backup_gpt-aemv8a.gpt-debug
copy to group/tftf-l2-fvp/fvp-gpt,fvp-default:fvp-tftf.header_backup_gpt-aemv8a.gpt-debug
diff --git a/run_config/fvp-tftf.backup_gpt b/run_config/fvp-tftf.entries_backup_gpt
similarity index 68%
copy from run_config/fvp-tftf.backup_gpt
copy to run_config/fvp-tftf.entries_backup_gpt
index 780697d..51df98e 100644
--- a/run_config/fvp-tftf.backup_gpt
+++ b/run_config/fvp-tftf.entries_backup_gpt
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
-# Copyright (c) 2023-2024, Arm Limited. All rights reserved.
+# Copyright (c) 2024, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -13,8 +13,8 @@
# Maximum FIP size is 2MiB = 2097152
gen_gpt_bin "$archive/fip.bin" 2097152
- # Corrupt primary GPT header to force TF-A to use the backup one
- corrupt_gpt_bin "$archive/fip_gpt.bin"
+ # Corrupt primary GPT entries to force TF-A to use the backup
+ corrupt_gpt_bin "$archive/fip_gpt.bin" "partition-entries"
}
generate_lava_job_template() {
diff --git a/run_config/fvp-tftf.backup_gpt b/run_config/fvp-tftf.header_backup_gpt
similarity index 91%
rename from run_config/fvp-tftf.backup_gpt
rename to run_config/fvp-tftf.header_backup_gpt
index 780697d..b54084c 100644
--- a/run_config/fvp-tftf.backup_gpt
+++ b/run_config/fvp-tftf.header_backup_gpt
@@ -14,7 +14,7 @@
gen_gpt_bin "$archive/fip.bin" 2097152
# Corrupt primary GPT header to force TF-A to use the backup one
- corrupt_gpt_bin "$archive/fip_gpt.bin"
+ corrupt_gpt_bin "$archive/fip_gpt.bin" "header"
}
generate_lava_job_template() {