platform: msm_shared: Fix partition offset overflow in avb

The partition offset maybe is more than 32bit, so define the UINTN
as uint64_t instead of uintptr_t to fix this problem.

Change-Id: I2b61ac962abf1009de5950113eb7222e44809cfd
diff --git a/platform/msm_shared/avb/VerifiedBoot.c b/platform/msm_shared/avb/VerifiedBoot.c
index fc14754..4150f9a 100644
--- a/platform/msm_shared/avb/VerifiedBoot.c
+++ b/platform/msm_shared/avb/VerifiedBoot.c
@@ -476,7 +476,7 @@
 	}
 
 	if (Info->num_loaded_images < NumRequestedPartition) {
-		dprintf(CRITICAL, "ERROR: AvbSlotVerify slot data: num of loaded partitions %d, requested %lu\n",Info->num_loaded_images, NumRequestedPartition);
+		dprintf(CRITICAL, "ERROR: AvbSlotVerify slot data: num of loaded partitions %d, requested %llu\n",Info->num_loaded_images, NumRequestedPartition);
 		Status = EFI_LOAD_ERROR;
 		goto out;
 	}
diff --git a/platform/msm_shared/avb/libavb/avb_ops.c b/platform/msm_shared/avb/libavb/avb_ops.c
index d8416ab..8c56f71 100644
--- a/platform/msm_shared/avb/libavb/avb_ops.c
+++ b/platform/msm_shared/avb/libavb/avb_ops.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2017-2018 The Android Open Source Project
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -186,7 +186,7 @@
 	ptn = partition_get_offset(index);
 
 	if (ReadOffset < 0) {
-		if ((-ReadOffset) > ptn) {
+		if ((-ReadOffset) > (int64_t)ptn) {
 			dprintf(CRITICAL,
 			       "Negative Offset outside range.\n");
 			Result = AVB_IO_RESULT_ERROR_RANGE_OUTSIDE_PARTITION;
@@ -211,7 +211,7 @@
 	}
 
 	dprintf(CRITICAL,
-	       "read from %s, 0x%x bytes at Offset 0x%x, partition size %lu\n",
+	       "read from %s, 0x%x bytes at Offset 0x%x, partition size %llu\n",
 	       Partition, NumBytes, Offset, ptn);
 
 	/* |NumBytes| and or |Offset| can be unaligned to block size/page size.
@@ -243,14 +243,14 @@
 		}
 
 		dprintf(DEBUG,
-		       "StartBlock 0x%x, ReadOffset 0x%x, read_size 0x%lx\n",
+		       "StartBlock 0x%x, ReadOffset 0x%x, read_size 0x%llx\n",
 		       StartBlock, StartPageReadOffset, StartPageReadSize);
 		if (StartPageReadSize <= 0 || StartPageReadOffset >= PageSize ||
 		    StartPageReadSize > PageSize - StartPageReadOffset ||
 		    StartPageReadSize > NumBytes) {
 			dprintf(CRITICAL,
 			       "StartBlock 0x%x, ReadOffset 0x%x, read_size "
-			       "0x%lx outside range.\n",
+			       "0x%llx outside range.\n",
 			       StartBlock, StartPageReadOffset, StartPageReadSize);
 			Result = AVB_IO_RESULT_ERROR_RANGE_OUTSIDE_PARTITION;
 			goto out;
@@ -276,14 +276,14 @@
 		UINTN LastPageReadSize = (Offset + NumBytes) - ReadOffset2;
 
 		dprintf(DEBUG,
-		       "LastBlock 0x%x, ReadOffset 0x%x, read_size 0x%lx\n",
+		       "LastBlock 0x%x, ReadOffset 0x%x, read_size 0x%llx\n",
 		       LastBlock, LastPageReadOffset, LastPageReadSize);
 
 		if (LastPageReadSize <= 0 || LastPageReadSize >= PageSize ||
 		    LastPageReadSize > (NumBytes - *OutNumRead)) {
 			dprintf(CRITICAL,
 			       "LastBlock 0x%x, ReadOffset 0x%x, read_size "
-			       "0x%lx outside range.\n",
+			       "0x%llx outside range.\n",
 			       LastBlock, LastPageReadOffset, LastPageReadSize);
 			Result = AVB_IO_RESULT_ERROR_RANGE_OUTSIDE_PARTITION;
 			goto out;
@@ -309,14 +309,14 @@
 		    (NumBytes - StartPageReadSize) < FillPageReadSize) {
 			dprintf(CRITICAL,
 			       "FullBlock 0x%x, ReadOffset 0x%x, read_size "
-			       "0x%lx outside range.\n",
+			       "0x%llx outside range.\n",
 			       FullBlock, 0, FillPageReadSize);
 			Result = AVB_IO_RESULT_ERROR_RANGE_OUTSIDE_PARTITION;
 			goto out;
 		}
 			dprintf(SPEW,
 			       "FullBlock 0x%x, ReadOffset 0x%x, read_size "
-			       "0x%lx outside range. StartPageReadSize %#lx PageSize %d ptn %#lx Buffer %p\n",
+			       "0x%llx outside range. StartPageReadSize %#llx PageSize %d ptn %#llx Buffer %p\n",
 			       FullBlock, 0, FillPageReadSize, StartPageReadSize, PageSize, ptn, Buffer);
 		Status = mmc_read(ptn + FullBlock * PageSize, Buffer + StartPageReadSize,
 					FillPageReadSize);
diff --git a/platform/msm_shared/include/verifiedboot.h b/platform/msm_shared/include/verifiedboot.h
index 9e16982..7534c14 100644
--- a/platform/msm_shared/include/verifiedboot.h
+++ b/platform/msm_shared/include/verifiedboot.h
@@ -105,7 +105,7 @@
 typedef int16_t   INT16;
 typedef int32_t   INT32;
 typedef int64_t   INT64;
-typedef uintptr_t UINTN;
+typedef uint64_t  UINTN;
 
 typedef enum {
 	VB_UNDEFINED_HASH	= 0,