Add debug printouts and fix existing ones

Signed-off-by: Fuad Tabba <tabba@google.com>
diff --git a/util/util.c b/util/util.c
index 12aa039..300cdfd 100644
--- a/util/util.c
+++ b/util/util.c
@@ -168,6 +168,9 @@
 	void *addr_map, *addr_align;
 	int fd;
 
+	pr_debug("Trying to allocate %llu bytes, total map %llu, guest_memfd %d",
+		 size, total_map, kvm->cfg.guest_memfd);
+
 	align_sz = max(align_sz, (u64)PAGE_SIZE);
 
 	/*
@@ -190,20 +193,25 @@
 	/* Create a mapping with room for alignment without allocating. */
 	addr_map = mmap(NULL, total_map, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS,
 			-1, 0);
-	if (addr_map == MAP_FAILED)
+	if (addr_map == MAP_FAILED) {
+		pr_warning("addr_map failed");
 		return MAP_FAILED;
+	}
 
 	if (kvm->cfg.guest_memfd)
 		fd = guest_memfd_alloc(kvm, size, hugetlbfs_path, blk_size);
 	else
 		fd = memfd_alloc(kvm, size, hugetlbfs_path, blk_size);
-	if (fd < 0)
+	if (fd < 0) {
+		pr_warning("alloc failed");
 		return MAP_FAILED;
+	}
 
 	/* Map the allocated memory in the fd to the specified alignment. */
 	addr_align = (void *)ALIGN((u64)addr_map, align_sz);
 	if (mmap(addr_align, size, PROT_RW, MAP_SHARED | MAP_FIXED, fd, 0) ==
 	    MAP_FAILED) {
+		pr_warning("addr_align failed, addr_align is 0x%llx, addr_map is 0x%llx", (u64)addr_align, (u64)addr_map);
 		close(fd);
 		return MAP_FAILED;
 	}
diff --git a/x86/kvm-cpu.c b/x86/kvm-cpu.c
index b02ff65..6a4b6cc 100644
--- a/x86/kvm-cpu.c
+++ b/x86/kvm-cpu.c
@@ -130,7 +130,7 @@
 	struct kvm_msrs *vcpu = calloc(1, sizeof(*vcpu) + (sizeof(struct kvm_msr_entry) * nmsrs));
 
 	if (!vcpu)
-		die("out of memory");
+		die("%s out of memory", __func__);
 
 	return vcpu;
 }
diff --git a/x86/kvm.c b/x86/kvm.c
index af0fc80..fc19f79 100644
--- a/x86/kvm.c
+++ b/x86/kvm.c
@@ -165,7 +165,7 @@
 			mprotect(kvm->ram_start + KVM_32BIT_GAP_START, KVM_32BIT_GAP_SIZE, PROT_NONE);
 	}
 	if (kvm->ram_start == MAP_FAILED)
-		die("out of memory");
+		die("%s out of memory", __func__);
 
 	madvise(kvm->ram_start, kvm->ram_size, MADV_MERGEABLE);
 
@@ -180,8 +180,10 @@
 
 int kvm__get_vm_type(struct kvm *kvm)
 {
-	if (kvm->cfg.sw_protected)
+	if (kvm->cfg.sw_protected) {
+		pr_debug("Creating a KVM_X86_SW_PROTECTED_VM");
 		return KVM_X86_SW_PROTECTED_VM;
+	}
 
 	return KVM_VM_TYPE;
 }