summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2021-08-05 16:59:46 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2021-08-05 16:59:46 -0700
commitd34abfde3a9210b8d44254aa379e04a14b0824cd (patch)
treeabbc23b55513a7ed747beae78c365617042f197d
parent1dcf34b92b199e4fc8b609f741a5850816d0b5d8 (diff)
parent1256e721627e99f2ce5c0904917e7e3f73efc806 (diff)
Merge "dm-verity: Add flag to ignore on nand"
-rw-r--r--QcomModulePkg/Library/BootLib/LECmdLine.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/QcomModulePkg/Library/BootLib/LECmdLine.c b/QcomModulePkg/Library/BootLib/LECmdLine.c
index cbe61480e8..4c003ca425 100644
--- a/QcomModulePkg/Library/BootLib/LECmdLine.c
+++ b/QcomModulePkg/Library/BootLib/LECmdLine.c
@@ -30,12 +30,14 @@
#include <Library/PartitionTableUpdate.h>
#include "LECmdLine.h"
+#include "Board.h"
#include <Library/MemoryAllocationLib.h>
/* verity command line related structures */
#define MAX_VERITY_CMD_LINE 512
#define MAX_VERITY_SECTOR_LEN 12
#define MAX_VERITY_HASH_LEN 65
+#define MAX_VERITY_NAND_IGNORE_LEN 2
STATIC CONST CHAR8 *VeritySystemPartitionStr = "/dev/mmcblk0p";
STATIC CONST CHAR8 *VerityName = "verity";
STATIC CONST CHAR8 *VerityAppliedOn = "system";
@@ -143,6 +145,7 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
INT32 HashSize = 0;
CHAR8 *Hash = NULL;
CHAR8 *FecOff = NULL;
+ CHAR8 *NandIgnore = NULL;
CHAR8 *DMDataStr = NULL;
BOOLEAN MultiSlotBoot = FALSE;
CHAR16 PartitionName[MAX_GPT_NAME_SIZE];
@@ -213,6 +216,21 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
DEBUG ((EFI_D_ERROR, "GetLEVerityCmdLine: Fec Offset error \n"));
goto ErrLEVerityout;
}
+ DMDataStr += Length;
+
+ NandIgnore = AllocateZeroPool (sizeof (CHAR8) * MAX_VERITY_NAND_IGNORE_LEN);
+ if (!NandIgnore) {
+ DEBUG ((EFI_D_ERROR, "Failed to allocate memory for NandIgnore\n"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ErrLEVerityout;
+ }
+
+ Status = LEVerityWordnCpy ((CHAR8 *) &NandIgnore[0],
+ MAX_VERITY_NAND_IGNORE_LEN, DMDataStr, &Length);
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "GetLEVerityCmdLine: Nand Ignore error \n"));
+ goto ErrLEVerityout;
+ }
/* Get HashSize which is always greater by 8 bytes to DataSize */
HashSize = AsciiStrDecimalToUintn ((CHAR8 *) &DataSize[0]) + 8;
@@ -244,6 +262,27 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
goto ErrLEVerityout;
}
+ CHAR8 RootDevStr[BOOT_DEV_NAME_SIZE_MAX];
+ GetRootDeviceType (RootDevStr, BOOT_DEV_NAME_SIZE_MAX);
+ if (!AsciiStrCmp ("NAND", RootDevStr)) {
+ /*
+ * If Nand Ignore flag set, do not append verity cmdline parameters.
+ * This is to support a use case where same boot image may be used
+ * by emmc and nand but nand does not support read-only limitations
+ */
+ if (!AsciiStrCmp ("1", NandIgnore)) {
+ *LEVerityCmdLine = AllocateZeroPool (1);
+ if (!*LEVerityCmdLine) {
+ DEBUG ((EFI_D_ERROR, "LEVerityCmdLine buffer: Out of resources\n"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ErrLEVerityout;
+ }
+ AsciiStrCpyS (*LEVerityCmdLine, 1, "");
+ *Len = 1;
+ goto ErrLEVerityout;
+ }
+ }
+
/* Construct complete verity command line */
if (AsciiStrCmp (FecOff, "0") == 0) {
AsciiSPrint (
@@ -306,6 +345,10 @@ ErrLEVerityout:
FreePool (FecOff);
FecOff = NULL;
}
+ if (NandIgnore != NULL) {
+ FreePool (NandIgnore);
+ NandIgnore = NULL;
+ }
if (DMTemp != NULL) {
FreePool (DMTemp);
DMTemp = NULL;