app/aboot, platform/msm_shared: Add boot state to kernel command line
Verified boot update requires the boot state to be appended to the kernel
command line.
Change-Id: I424e7a6896e7134a0766ce9eae19b6b19d65d7be
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index bf9c4db..0607cdd 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -167,6 +167,19 @@
static const char *baseband_sglte2 = " androidboot.baseband=sglte2";
static const char *warmboot_cmdline = " qpnp-power-on.warm_boot=1";
+#if VERIFIED_BOOT
+static const char *verified_state= " androidboot.verifiedbootstate=";
+
+//indexed based on enum values, green is 0 by default
+struct verified_boot_state_name vbsn[] =
+{
+ {GREEN, "green"},
+ {ORANGE, "orange"},
+ {YELLOW,"yellow"},
+ {RED,"red" },
+};
+#endif
+
static unsigned page_size = 0;
static unsigned page_mask = 0;
static char ffbm_mode_string[FFBM_MODE_BUF_SIZE];
@@ -263,6 +276,10 @@
int have_target_boot_params = 0;
char *boot_dev_buf = NULL;
bool is_mdtp_activated = 0;
+#if VERIFIED_BOOT
+ uint32_t boot_state = boot_verify_get_state();
+#endif
+
#ifdef MDTP_SUPPORT
mdtp_activated(&is_mdtp_activated);
#endif /* MDTP_SUPPORT */
@@ -284,6 +301,10 @@
cmdline_len += strlen(usb_sn_cmdline);
cmdline_len += strlen(sn_buf);
+#if VERIFIED_BOOT
+ cmdline_len += strlen(verified_state) + strlen(vbsn[boot_state].name);
+#endif
+
if (boot_into_recovery && gpt_exists)
cmdline_len += strlen(secondary_gpt_enable);
@@ -398,6 +419,15 @@
#endif
}
+#if VERIFIED_BOOT
+ src = verified_state;
+ if(have_cmdline) --dst;
+ have_cmdline = 1;
+ while ((*dst++ = *src++));
+ src = vbsn[boot_state].name;
+ if(have_cmdline) --dst;
+ while ((*dst++ = *src++));
+#endif
src = usb_sn_cmdline;
if (have_cmdline) --dst;
have_cmdline = 1;
diff --git a/platform/msm_shared/include/boot_verifier.h b/platform/msm_shared/include/boot_verifier.h
index bc61524..5643288 100644
--- a/platform/msm_shared/include/boot_verifier.h
+++ b/platform/msm_shared/include/boot_verifier.h
@@ -138,6 +138,12 @@
RED,
};
+struct verified_boot_state_name
+{
+ uint32_t boot_state;
+ char *name;
+};
+
enum boot_verfiy_event
{
BOOT_INIT,