Merge "target: msm8909: Update cmdline boot params as per the rootfs"
diff --git a/AndroidBoot.mk b/AndroidBoot.mk
index 85c917d..f8fb87f 100644
--- a/AndroidBoot.mk
+++ b/AndroidBoot.mk
@@ -92,7 +92,7 @@
 
 # Top level for eMMC variant targets
 $(TARGET_EMMC_BOOTLOADER): emmc_appsbootldr_clean | $(EMMC_BOOTLOADER_OUT) $(INSTALLED_KEYSTOREIMAGE_TARGET)
-	$(MAKE) -C bootable/bootloader/lk TOOLCHAIN_PREFIX=$(CROSS_COMPILE) BOOTLOADER_OUT=../../../$(EMMC_BOOTLOADER_OUT) $(BOOTLOADER_PLATFORM) EMMC_BOOT=1 $(SIGNED_KERNEL) $(VERIFIED_BOOT) $(DEVICE_STATUS) $(BUILD_VARIANT) $(BOARD_NAME)
+	$(MAKE) -C bootable/bootloader/lk TOOLCHAIN_PREFIX=$(CROSS_COMPILE) BOOTLOADER_OUT=../../../$(EMMC_BOOTLOADER_OUT) $(BOOTLOADER_PLATFORM) EMMC_BOOT=1 $(SIGNED_KERNEL) $(VERIFIED_BOOT) $(DEVICE_STATUS) $(BUILD_VARIANT) $(BOARD_NAME) $(ENABLE_VB_ATTEST) $(OSVERSION_IN_BOOTIMAGE)
 
 # Keep build NAND & eMMC as default for targets still using TARGET_BOOTLOADER
 TARGET_BOOTLOADER := $(PRODUCT_OUT)/EMMCBOOT.MBN
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index e545660..57c817a 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -1726,16 +1726,26 @@
 
 		bs_set_timestamp(BS_KERNEL_LOAD_START);
 
+		if (UINT_MAX - offset < kernel_actual)
+		{
+			dprintf(CRITICAL, "ERROR: Integer overflow in boot image header %s\t%d\n",__func__,__LINE__);
+			return -1;
+		}
 		if (flash_read(ptn, offset, (void *)hdr->kernel_addr, kernel_actual)) {
 			dprintf(CRITICAL, "ERROR: Cannot read kernel image\n");
 			return -1;
 		}
 		offset += kernel_actual;
-
+		if (UINT_MAX - offset < ramdisk_actual)
+		{
+			dprintf(CRITICAL, "ERROR: Integer overflow in boot image header %s\t%d\n",__func__,__LINE__);
+			return -1;
+		}
 		if (flash_read(ptn, offset, (void *)hdr->ramdisk_addr, ramdisk_actual)) {
 			dprintf(CRITICAL, "ERROR: Cannot read ramdisk image\n");
 			return -1;
 		}
+
 		offset += ramdisk_actual;
 
 		dprintf(INFO, "Loading (%s) image (%d): done\n",
@@ -1744,6 +1754,11 @@
 		bs_set_timestamp(BS_KERNEL_LOAD_DONE);
 
 		if(hdr->second_size != 0) {
+			if (UINT_MAX - offset < second_actual)
+			{
+				dprintf(CRITICAL, "ERROR: Integer overflow in boot image header %s\t%d\n",__func__,__LINE__);
+				return -1;
+			}
 			offset += second_actual;
 			/* Second image loading not implemented. */
 			ASSERT(0);
diff --git a/platform/msm_shared/mdp5.c b/platform/msm_shared/mdp5.c
index a5db243..ade5065 100755
--- a/platform/msm_shared/mdp5.c
+++ b/platform/msm_shared/mdp5.c
@@ -1017,11 +1017,18 @@
 
 		if (pinfo->lcdc.dual_pipe && !pinfo->mipi.dual_dsi &&
 		    !pinfo->lcdc.split_display && (pinfo->num_dsc_enc == 2)) {
-
 			dsc->mdp_dsc_config(pinfo, MDP_PP_0_BASE,
 				MDP_DSC_0_BASE, true, true);
 			dsc->mdp_dsc_config(pinfo, MDP_PP_1_BASE,
 				MDP_DSC_1_BASE, true, true);
+
+		} else if (pinfo->lcdc.dual_pipe && pinfo->mipi.dual_dsi &&
+		    pinfo->lcdc.split_display && (pinfo->num_dsc_enc == 1)) {
+			dsc->mdp_dsc_config(pinfo, MDP_PP_0_BASE,
+				MDP_DSC_0_BASE, false, false);
+			dsc->mdp_dsc_config(pinfo, MDP_PP_1_BASE,
+				MDP_DSC_1_BASE, false, false);
+
 		} else {
 			dsc->mdp_dsc_config(pinfo, MDP_PP_0_BASE,
 				MDP_DSC_0_BASE, false, false);
diff --git a/platform/msm_shared/mipi_dsc.c b/platform/msm_shared/mipi_dsc.c
index c581855..c1578df 100644
--- a/platform/msm_shared/mipi_dsc.c
+++ b/platform/msm_shared/mipi_dsc.c
@@ -224,7 +224,10 @@
 	}
 	dsc->range_bpg_offset = dsc_rc_range_bpg_offset;
 
-	dsc->pic_width = pinfo->xres;
+	if (pinfo->mipi.dual_dsi)
+		dsc->pic_width = pinfo->xres / 2;
+	else
+		dsc->pic_width = pinfo->xres;
 	dsc->pic_height = pinfo->yres;
 
 	bpp = dsc->bpp;
diff --git a/platform/msm_shared/rpmb/rpmb.c b/platform/msm_shared/rpmb/rpmb.c
index ec31ccf..e3c7e9f 100644
--- a/platform/msm_shared/rpmb/rpmb.c
+++ b/platform/msm_shared/rpmb/rpmb.c
@@ -52,7 +52,9 @@
 	{
 		struct mmc_device *mmc_dev = (struct mmc_device *) dev;
 		info.size = mmc_dev->card.rpmb_size / RPMB_MIN_BLK_SZ;
-		if (mmc_dev->card.ext_csd[MMC_EXT_CSD_REV] < 8)
+
+		if ((mmc_dev->card.ext_csd !=NULL) &&
+			(mmc_dev->card.ext_csd[MMC_EXT_CSD_REV] < 8))
 		{
 			//as per emmc spec rel_wr_count should be 1 for emmc version < 5.1
 			dprintf(SPEW, "EMMC Version < 5.1\n");
@@ -60,7 +62,8 @@
 		}
 		else
 		{
-			if ( (mmc_dev->card.ext_csd[MMC_EXT_CSD_EN_RPMB_REL_WR] & BIT(4)) == 0)
+			if ((mmc_dev->card.ext_csd !=NULL) &&
+				((mmc_dev->card.ext_csd[MMC_EXT_CSD_EN_RPMB_REL_WR] & BIT(4)) == 0))
 			{
 				dprintf(SPEW, "EMMC Version >= 5.1 EN_RPMB_REL_WR = 0\n");
 				// according to emmc version 5.1 and above if EN_RPMB_REL_WR in extended
diff --git a/project/msm8996.mk b/project/msm8996.mk
index 8278849..3f51b81 100644
--- a/project/msm8996.mk
+++ b/project/msm8996.mk
@@ -58,7 +58,7 @@
 ENABLE_THUMB := false
 
 #enable fbcon display menu
-ENABLE_FBCON_DISPLAY_MSG := 0
+ENABLE_FBCON_DISPLAY_MSG := 1
 
 ifeq ($(ENABLE_FBCON_DISPLAY_MSG),1)
 DEFINES += FBCON_DISPLAY_MSG=1
diff --git a/target/mdm9640/init.c b/target/mdm9640/init.c
index 219d0f8..2429cb9 100644
--- a/target/mdm9640/init.c
+++ b/target/mdm9640/init.c
@@ -189,21 +189,49 @@
 		target_crypto_init_params();
 }
 
-/* reboot */
+static int scm_clear_boot_partition_select()
+{
+	int ret = 0;
+
+	ret = scm_call_atomic2(SCM_SVC_BOOT, WDOG_DEBUG_DISABLE, 1, 0);
+	if (ret)
+		dprintf(CRITICAL, "Failed to disable the wdog debug \n");
+
+	return ret;
+}
+
+/* Trigger reboot */
 void reboot_device(unsigned reboot_reason)
 {
+	uint8_t reset_type = 0;
+
+	if (platform_is_mdmcalifornium())
+	{
+		/* Clear the boot partition select cookie to indicate
+		 * its a normal reset and avoid going to download mode */
+		scm_clear_boot_partition_select();
+	}
+
 	/* Write the reboot reason */
 	writel(reboot_reason, RESTART_REASON_ADDR);
 
-	/* Configure PMIC for warm reset */
-	/* PM 8019 v1 aligns with PM8941 v2.
-	 * This call should be based on the pmic version
-	 * when PM8019 v2 is available.
-	 */
-	if (reboot_reason)
-		pm8x41_v2_reset_configure(PON_PSHOLD_WARM_RESET);
+	if(reboot_reason)
+		reset_type = PON_PSHOLD_WARM_RESET;
 	else
-		pm8x41_v2_reset_configure(PON_PSHOLD_HARD_RESET);
+		reset_type = PON_PSHOLD_HARD_RESET;
+
+	if (platform_is_mdmcalifornium())
+	{
+		/* PMD9655 is the PMIC used for MDMcalifornium */
+		pm8x41_reset_configure(reset_type);
+	} else {
+		/* Configure PMIC for warm reset */
+		/* PM 8019 v1 aligns with PM8941 v2.
+		 * This call should be based on the pmic version
+		 * when PM8019 v2 is available.
+		 */
+		pm8x41_v2_reset_configure(reset_type);
+	}
 
 	/* Drop PS_HOLD for MSM */
 	writel(0x00, MPM2_MPM_PS_HOLD);