vulkan-cereal: use void* instead of uint64_t for hva

This simplifies the code a bit.  The page-alignment logic is removed
from virtio-gpu-gfxstream-renderer and kept in the Vulkan decoder
-- the original case for that was when the Nvidia Linux driver wasn't
aligning mappings to page bounders.

That should not affect ASG mappings.

BUG=235485545
TEST=compile

Change-Id: Iebe1f003f9b7e145b2fab20b2125f5525ae34d28
diff --git a/host-common/HostmemIdMapping_unittest.cpp b/host-common/HostmemIdMapping_unittest.cpp
index eeb90ac..00df2f9 100644
--- a/host-common/HostmemIdMapping_unittest.cpp
+++ b/host-common/HostmemIdMapping_unittest.cpp
@@ -28,7 +28,7 @@
     HostmemIdMapping m;
     {
         MemEntry entry{
-            .hva = 0,
+            .hva = (void *)(uintptr_t)0,
             .size = 1,
             .register_fixed = 0,
             .fixed_id = 0,
@@ -39,7 +39,7 @@
     }
     {
         MemEntry entry{
-            .hva = 1,
+            .hva = (void *)(uintptr_t) 1,
             .size = 0,
             .register_fixed = 0,
             .fixed_id = 0,
@@ -50,7 +50,7 @@
     }
     {
         MemEntry inputEntry{
-            .hva = 1,
+            .hva = (void *)(uintptr_t) 1,
             .size = 2,
             .register_fixed = 0,
             .fixed_id = 0,
@@ -61,7 +61,7 @@
 
         auto entry = m.get(id);
         EXPECT_EQ(id, entry.id);
-        EXPECT_EQ(1, entry.hva);
+        EXPECT_EQ(1, (uint64_t)(uintptr_t)entry.hva);
         EXPECT_EQ(2, entry.size);
 
         m.remove(id);
@@ -69,7 +69,7 @@
         entry = m.get(id);
 
         EXPECT_EQ(HostmemIdMapping::kInvalidHostmemId, entry.id);
-        EXPECT_EQ(0, entry.hva);
+        EXPECT_EQ(0, (uint64_t)(uintptr_t)entry.hva);
         EXPECT_EQ(0, entry.size);
     }
 }
@@ -78,7 +78,7 @@
 TEST(HostmemIdMapping, Clear) {
     HostmemIdMapping m;
     MemEntry entry1{
-        .hva = 1,
+        .hva = (void *)(uintptr_t) 1,
         .size = 2,
         .register_fixed = 0,
         .fixed_id = 0,
@@ -86,7 +86,7 @@
     };
     auto id1 = m.add(&entry1);
     MemEntry entry2{
-        .hva = 3,
+        .hva = (void *)(uintptr_t) 3,
         .size = 4,
         .register_fixed = 0,
         .fixed_id = 0,
@@ -98,12 +98,12 @@
 
     auto entry = m.get(id1);
     EXPECT_EQ(HostmemIdMapping::kInvalidHostmemId, entry.id);
-    EXPECT_EQ(0, entry.hva);
+    EXPECT_EQ(0, (uint64_t)(uintptr_t)entry.hva);
     EXPECT_EQ(0, entry.size);
 
     entry = m.get(id2);
     EXPECT_EQ(HostmemIdMapping::kInvalidHostmemId, entry.id);
-    EXPECT_EQ(0, entry.hva);
+    EXPECT_EQ(0, (uint64_t)(uintptr_t)entry.hva);
     EXPECT_EQ(0, entry.size);
 }
 
diff --git a/host-common/address_space_graphics.cpp b/host-common/address_space_graphics.cpp
index e293a05..22d166b 100644
--- a/host-common/address_space_graphics.cpp
+++ b/host-common/address_space_graphics.cpp
@@ -435,7 +435,7 @@
                     buf = aligned_buf_alloc(ADDRESS_SPACE_GRAPHICS_PAGE_SIZE, create.size);
 
                     struct MemEntry entry = { 0 };
-                    entry.hva = (uint64_t)(uintptr_t)buf;
+                    entry.hva = buf;
                     entry.size = create.size;
                     entry.register_fixed = create.hostmemRegisterFixed;
                     entry.fixed_id = create.hostmemId ? create.hostmemId : 0;
diff --git a/host-common/include/host-common/vm_operations.h b/host-common/include/host-common/vm_operations.h
index 44fa264..cfee73b 100644
--- a/host-common/include/host-common/vm_operations.h
+++ b/host-common/include/host-common/vm_operations.h
@@ -34,14 +34,14 @@
 // with a host memory id. Used with virtio-gpu-next.
 struct HostmemEntry {
     uint64_t id;
-    uint64_t hva;
+    void* hva;
     uint64_t size;
     uint32_t caching;
 };
 
 // Called by hostmemRegister(..)
 struct MemEntry {
-    uint64_t hva;
+    void* hva;
     uint64_t size;
     uint32_t register_fixed;
     uint64_t fixed_id;
diff --git a/stream-servers/virtio-gpu-gfxstream-renderer.cpp b/stream-servers/virtio-gpu-gfxstream-renderer.cpp
index a8b601b..bda8897 100644
--- a/stream-servers/virtio-gpu-gfxstream-renderer.cpp
+++ b/stream-servers/virtio-gpu-gfxstream-renderer.cpp
@@ -185,7 +185,7 @@
     size_t linearSize;
     GoldfishHostPipe* hostPipe;
     VirtioGpuCtxId ctxId;
-    uint64_t hva;
+    void* hva;
     uint64_t hvaSize;
     uint64_t blobId;
     uint32_t hvSlot;
@@ -1034,7 +1034,7 @@
         e.args = *args;
         e.linear = 0;
         e.hostPipe = 0;
-        e.hva = 0;
+        e.hva = nullptr;
         e.hvaSize = 0;
         e.blobId = 0;
         e.hvSlot = 0;
@@ -1085,7 +1085,7 @@
             entry.numIovs = 0;
         }
 
-        entry.hva = 0;
+        entry.hva = nullptr;
         entry.hvaSize = 0;
         entry.blobId = 0;
         entry.hvSlot = 0;
@@ -1525,18 +1525,8 @@
 
         const auto& entry = it->second;
 
-        static const uint64_t kPageSizeforBlob = 4096;
-        static const uint64_t kPageMaskForBlob = ~(0xfff);
-
-        uint64_t alignedHva =
-            entry.hva & kPageMaskForBlob;
-
-        uint64_t alignedSize =
-            kPageSizeforBlob *
-            ((entry.hvaSize + kPageSizeforBlob - 1) / kPageSizeforBlob);
-
-        if (hvaOut) *hvaOut = (void*)(uintptr_t)alignedHva;
-        if (sizeOut) *sizeOut = alignedSize;
+        if (hvaOut) *hvaOut = entry.hva;
+        if (sizeOut) *sizeOut = entry.hvaSize;
         return 0;
     }
 
diff --git a/stream-servers/vulkan/VkDecoderGlobalState.cpp b/stream-servers/vulkan/VkDecoderGlobalState.cpp
index ac1e695..7220aec 100644
--- a/stream-servers/vulkan/VkDecoderGlobalState.cpp
+++ b/stream-servers/vulkan/VkDecoderGlobalState.cpp
@@ -110,6 +110,9 @@
 static constexpr uint32_t kMaxSafeVersion = VK_MAKE_VERSION(1, 1, 0);
 static constexpr uint32_t kMinVersion = VK_MAKE_VERSION(1, 0, 0);
 
+static constexpr uint64_t kPageSizeforBlob = 4096;
+static constexpr uint64_t kPageMaskForBlob = ~(0xfff);
+
 #define DEFINE_BOXED_HANDLE_TYPE_TAG(type) Tag_##type,
 
 enum BoxedHandleTypeTag {
@@ -3637,28 +3640,25 @@
         uint64_t hva = (uint64_t)(uintptr_t)(info->ptr);
         uint64_t size = (uint64_t)(uintptr_t)(info->size);
 
-        constexpr size_t kPageBits = 12;
-        constexpr size_t kPageSize = 1u << kPageBits;
-        constexpr size_t kPageOffsetMask = kPageSize - 1;
+        uint64_t alignedHva = hva & kPageMaskForBlob;
+        uint64_t alignedSize = kPageSizeforBlob *
+                               ((size + kPageSizeforBlob - 1) / kPageSizeforBlob);
 
-        uint64_t pageOffset = hva & kPageOffsetMask;
-        uint64_t sizeToPage = ((size + pageOffset + kPageSize - 1) >> kPageBits) << kPageBits;
-
-        entry.hva = (uint64_t)(uintptr_t)(info->ptr);
-        entry.size = (uint64_t)(uintptr_t)(info->size);
+        entry.hva = (void*)(uintptr_t)alignedHva;
+        entry.size = alignedSize;
         entry.caching = info->caching;
 
         auto id = get_emugl_vm_operations().hostmemRegister(&entry);
 
         *pAddress = hva & (0xfff);  // Don't expose exact hva to guest
-        *pSize = sizeToPage;
+        *pSize = alignedSize;
         *pHostmemId = id;
 
         info->virtioGpuMapped = true;
         info->hostmemId = id;
 
         fprintf(stderr, "%s: hva, size, sizeToPage: %p 0x%llx 0x%llx id 0x%llx\n", __func__,
-                info->ptr, (unsigned long long)(info->size), (unsigned long long)(sizeToPage),
+                info->ptr, (unsigned long long)(info->size), (unsigned long long)(alignedSize),
                 (unsigned long long)(*pHostmemId));
         return VK_SUCCESS;
     }