summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2021-09-03 18:34:05 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2021-09-03 18:34:05 -0700
commite32787a7f0d452fd907b6384d964167aac7f5f83 (patch)
tree8f42c76de7e43e634cb815fc3cfaa09a2516913c
parent2943e5b4f38c85d49d65194735824013bc75290d (diff)
parent595f1f20a52c6d0c26e5e628de13f81045f58386 (diff)
Merge "edk2: gluebi/dm-verity support for nand targets"
-rw-r--r--QcomModulePkg/Library/BootLib/LECmdLine.c44
-rw-r--r--QcomModulePkg/Library/BootLib/LECmdLine.h4
-rw-r--r--QcomModulePkg/Library/BootLib/UpdateCmdLine.c17
3 files changed, 54 insertions, 11 deletions
diff --git a/QcomModulePkg/Library/BootLib/LECmdLine.c b/QcomModulePkg/Library/BootLib/LECmdLine.c
index 4c003ca425..221c6f4ea6 100644
--- a/QcomModulePkg/Library/BootLib/LECmdLine.c
+++ b/QcomModulePkg/Library/BootLib/LECmdLine.c
@@ -38,7 +38,9 @@
#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";
+#define MAX_VERITY_SYSTEM_PARTITION_STR_LEN 20
+STATIC CONST CHAR8 *VeritySystemPartitionStrEmmc = "/dev/mmcblk0p";
+STATIC CONST CHAR8 *VeritySystemPartitionStrNand = "/dev/ubiblock0_0";
STATIC CONST CHAR8 *VerityName = "verity";
STATIC CONST CHAR8 *VerityAppliedOn = "system";
STATIC CONST CHAR8 *VerityEncriptionName = "sha256";
@@ -53,17 +55,29 @@ STATIC CONST CHAR8 *FecRoot = "fec_roots";
STATIC CONST CHAR8 *FecBlock = "fec_blocks";
STATIC CONST CHAR8 *FecStart = "fec_start";
+STATIC BOOLEAN LEVerityNandIgnore;
+
#define FEATUREARGS 10
#if VERITY_LE
BOOLEAN IsLEVerity (VOID)
{
return TRUE;
}
+
+BOOLEAN IsLEVerityNandIgnore (VOID)
+{
+ return LEVerityNandIgnore;
+}
#else
BOOLEAN IsLEVerity (VOID)
{
return FALSE;
}
+
+BOOLEAN IsLEVerityNandIgnore (VOID)
+{
+ return FALSE;
+}
#endif
/**
@@ -151,6 +165,8 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
CHAR16 PartitionName[MAX_GPT_NAME_SIZE];
INT32 Index = 0;
+ LEVerityNandIgnore = FALSE;
+
/* Get verity command line from SourceCmdLine */
DMDataStr = AsciiStrStr (SourceCmdLine, "verity=");
@@ -262,6 +278,7 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
goto ErrLEVerityout;
}
+ CHAR8 VeritySystemPartitionStr[MAX_VERITY_SYSTEM_PARTITION_STR_LEN];
CHAR8 RootDevStr[BOOT_DEV_NAME_SIZE_MAX];
GetRootDeviceType (RootDevStr, BOOT_DEV_NAME_SIZE_MAX);
if (!AsciiStrCmp ("NAND", RootDevStr)) {
@@ -271,6 +288,7 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
* by emmc and nand but nand does not support read-only limitations
*/
if (!AsciiStrCmp ("1", NandIgnore)) {
+ LEVerityNandIgnore = TRUE;
*LEVerityCmdLine = AllocateZeroPool (1);
if (!*LEVerityCmdLine) {
DEBUG ((EFI_D_ERROR, "LEVerityCmdLine buffer: Out of resources\n"));
@@ -281,6 +299,20 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
*Len = 1;
goto ErrLEVerityout;
}
+ AsciiSPrint (
+ VeritySystemPartitionStr,
+ MAX_VERITY_SYSTEM_PARTITION_STR_LEN,
+ "%a",
+ VeritySystemPartitionStrNand
+ );
+ } else {
+ /* Append index to EMMC partition string */
+ AsciiSPrint (
+ VeritySystemPartitionStr,
+ MAX_VERITY_SYSTEM_PARTITION_STR_LEN,
+ "%a%d",
+ VeritySystemPartitionStrEmmc, Index
+ );
}
/* Construct complete verity command line */
@@ -288,9 +320,9 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
AsciiSPrint (
DMTemp,
MAX_VERITY_CMD_LINE,
- " %a dm-mod.create=\"%a,,,ro,0 %a %a 1 %a%d %a%d %a %a %a %d %a %a %a\"",
+ " %a dm-mod.create=\"%a,,,ro,0 %a %a 1 %a %a %a %a %a %d %a %a %a\"",
VerityRoot, VerityAppliedOn, SectorSize, VerityName,
- VeritySystemPartitionStr, Index, VeritySystemPartitionStr, Index,
+ VeritySystemPartitionStr, VeritySystemPartitionStr,
VerityBlockSize, VerityBlockSize, DataSize, HashSize, VerityEncriptionName,
Hash, VeritySalt
);
@@ -299,12 +331,12 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
AsciiSPrint (
DMTemp,
MAX_VERITY_CMD_LINE,
- " %a dm-mod.create=\"%a,,,ro,0 %a %a 1 %a%d %a%d %a %a %a %d %a %a %a %d %a %a %a %a%d %a 2 %a %a %a %a\"",
+ " %a dm-mod.create=\"%a,,,ro,0 %a %a 1 %a %a %a %a %a %d %a %a %a %d %a %a %a %a %a 2 %a %a %a %a\"",
VerityRoot, VerityAppliedOn, SectorSize, VerityName,
- VeritySystemPartitionStr, Index, VeritySystemPartitionStr, Index,
+ VeritySystemPartitionStr, VeritySystemPartitionStr,
VerityBlockSize, VerityBlockSize, DataSize, HashSize, VerityEncriptionName,
Hash, VeritySalt, FEATUREARGS, OptionalParam0, OptionalParam1, UseFec,
- VeritySystemPartitionStr, Index, FecRoot, FecBlock, FecOff, FecStart, FecOff
+ VeritySystemPartitionStr, FecRoot, FecBlock, FecOff, FecStart, FecOff
);
}
diff --git a/QcomModulePkg/Library/BootLib/LECmdLine.h b/QcomModulePkg/Library/BootLib/LECmdLine.h
index 627051d444..14f77893de 100644
--- a/QcomModulePkg/Library/BootLib/LECmdLine.h
+++ b/QcomModulePkg/Library/BootLib/LECmdLine.h
@@ -1,6 +1,6 @@
/** @file LECmdLine.h
*
- * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018, 2021 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -56,4 +56,6 @@ GetLEVerityCmdLine (CONST CHAR8 *SourceCmdLine,
**/
BOOLEAN IsLEVerity (VOID);
+BOOLEAN IsLEVerityNandIgnore (VOID);
+
#endif
diff --git a/QcomModulePkg/Library/BootLib/UpdateCmdLine.c b/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
index f9fbb9ab40..2829861a48 100644
--- a/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
+++ b/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
@@ -377,9 +377,17 @@ GetSystemPath (CHAR8 **SysPath, BootInfo *Info)
" rootfstype=squashfs root=/dev/mtdblock%d ubi.mtd=%d",
(PartitionCount - 1), (Index - 1));
} else {
- AsciiSPrint (*SysPath, MAX_PATH_SIZE,
- " rootfstype=ubifs rootflags=bulk_read root=ubi0:rootfs ubi.mtd=%d",
- (Index - 1));
+ if (IsLEVerity () &&
+ !Info->BootIntoRecovery &&
+ !IsLEVerityNandIgnore ()) {
+ AsciiSPrint (*SysPath, MAX_PATH_SIZE,
+ " rootfstype=ext4 ubi.mtd=%d ubi.block=0,0 root=/dev/dm-0",
+ (Index - 1));
+ } else {
+ AsciiSPrint (*SysPath, MAX_PATH_SIZE,
+ " rootfstype=ubifs rootflags=bulk_read root=ubi0:rootfs ubi.mtd=%d",
+ (Index - 1));
+ }
}
} else if (!AsciiStrCmp ("UFS", RootDevStr)) {
AsciiSPrint (*SysPath, MAX_PATH_SIZE, " root=/dev/sd%c%d",
@@ -922,7 +930,8 @@ UpdateCmdLine (CONST CHAR8 *CmdLine,
}
if (HaveCmdLine) {
- if (IsLEVerity ()) {
+ if (IsLEVerity () &&
+ !Recovery) {
Status = GetLEVerityCmdLine (CmdLine, &LEVerityCmdLine,
&LEVerityCmdLineLen);
if (Status != EFI_SUCCESS) {