From 25f917cbf08ef34b8f363054e39aa80d391fc4a9 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 8 Sep 2014 22:28:27 +0200
Subject: [PATCH 3/3] kprintf crap

---
 .../dev/virtual/vmware/vmmemctl/backdoor_balloon.c | 31 ++++++++++++++++++++++
 sys/gnu/dev/virtual/vmware/vmmemctl/os.c           |  5 ++++
 2 files changed, 36 insertions(+)

diff --git a/sys/gnu/dev/virtual/vmware/vmmemctl/backdoor_balloon.c b/sys/gnu/dev/virtual/vmware/vmmemctl/backdoor_balloon.c
index 7036d23..043855f 100644
--- a/sys/gnu/dev/virtual/vmware/vmmemctl/backdoor_balloon.c
+++ b/sys/gnu/dev/virtual/vmware/vmmemctl/backdoor_balloon.c
@@ -19,6 +19,7 @@
 #include "backdoor.h"
 #include "balloon_def.h"
 #include "os.h"
+#include <sys/systm.h>
 
 /*
  *----------------------------------------------------------------------
@@ -47,6 +48,8 @@ BackdoorCmd(uint16 cmd,     // IN
    Backdoor_proto bp;
    int status;
 
+   kprintf("%s: cmd:%d arg1:%zu arg2:%d out:%p resetFlag:%p\n",
+       __func__, cmd, arg1, arg2, out, resetFlag);
    /* prepare backdoor args */
    bp.in.cx.halfs.low = cmd;
    bp.in.size = arg1;
@@ -71,6 +74,9 @@ BackdoorCmd(uint16 cmd,     // IN
       }
    }
 
+   kprintf("%s: cmd:%d arg1:%zu arg2:%d out:%p resetFlag:%p\n",
+       __func__, cmd, arg1, arg2, out, resetFlag);
+   kprintf("%s: status:%d\n", __func__, status);
    return status;
 }
 
@@ -98,6 +104,9 @@ Backdoor_MonitorStart(Balloon *b,               // IN
    uint32 capabilities;
    int status = BackdoorCmd(BALLOON_BDOOR_CMD_START, protoVersion, 0,
                             &capabilities, &b->resetFlag);
+
+   kprintf("%s: b:%p protoVersion:%d status:%d\n",
+       __func__, b, protoVersion, status);
    /*
     * If return code is BALLOON_SUCCESS_WITH_CAPABILITY, then ESX is
     * sending the common capabilities supported by the monitor and the
@@ -142,6 +151,8 @@ Backdoor_MonitorGuestType(Balloon *b) // IN
    int status = BackdoorCmd(BALLOON_BDOOR_CMD_GUEST_ID, b->guestType, 0,
                             NULL, &b->resetFlag);
 
+   kprintf("%s: b:%p status:%d\n",
+       __func__, b, status);
    /* update stats */
    STATS_INC(b->stats.guestType);
    if (status != BALLOON_SUCCESS) {
@@ -188,10 +199,14 @@ Backdoor_MonitorGetTarget(Balloon *b,     // IN
    uint32 limit32;
    int status;
 
+   kprintf("%s: b:%p target:%p\n",
+       __func__, b, target);
    limit = OS_ReservedPageGetLimit();
 
    /* Ensure limit fits in 32-bits */
    limit32 = (uint32)limit;
+   kprintf("%s: limit:%lu limit32:%u\n",
+       __func__, limit, limit32);
    if (limit32 != limit) {
       return BALLOON_FAILURE;
    }
@@ -199,6 +214,8 @@ Backdoor_MonitorGetTarget(Balloon *b,     // IN
    status = BackdoorCmd(BALLOON_BDOOR_CMD_TARGET, limit, 0, target,
                         &b->resetFlag);
 
+   kprintf("%s: b:%p target:%p status:%d *target:%d\n",
+       __func__, b, target, status, *target);
    /* update stats */
    STATS_INC(b->stats.target);
    if (status != BALLOON_SUCCESS) {
@@ -235,6 +252,8 @@ Backdoor_MonitorLockPage(Balloon *b,    // IN
    int status;
    uint32 ppn32 = (uint32)ppn;
 
+   kprintf("%s: b:%p ppn:%lu ppn32:%u\n",
+       __func__, b, ppn, ppn32);
    /* Ensure PPN fits in 32-bits, i.e. guest memory is limited to 16TB. */
    if (ppn32 != ppn) {
       return BALLOON_ERROR_PPN_INVALID;
@@ -243,6 +262,8 @@ Backdoor_MonitorLockPage(Balloon *b,    // IN
    status = BackdoorCmd(BALLOON_BDOOR_CMD_LOCK, ppn32, 0, NULL,
                         &b->resetFlag);
 
+   kprintf("%s: b:%p ppn:%lu ppn32:%u status:%d\n",
+       __func__, b, ppn, ppn32, status);
    /* update stats */
    STATS_INC(b->stats.lock);
    if (status != BALLOON_SUCCESS) {
@@ -278,6 +299,8 @@ Backdoor_MonitorUnlockPage(Balloon *b,  // IN
    int status;
    uint32 ppn32 = (uint32)ppn;
 
+   kprintf("%s: b:%p ppn:%lu ppn32:%u\n",
+       __func__, b, ppn, ppn32);
    /* Ensure PPN fits in 32-bits, i.e. guest memory is limited to 16TB. */
    if (ppn32 != ppn) {
       return BALLOON_ERROR_PPN_INVALID;
@@ -286,6 +309,8 @@ Backdoor_MonitorUnlockPage(Balloon *b,  // IN
    status = BackdoorCmd(BALLOON_BDOOR_CMD_UNLOCK, ppn32, 0, NULL,
                         &b->resetFlag);
 
+   kprintf("%s: b:%p ppn:%lu ppn32:%u status:%d\n",
+       __func__, b, ppn, ppn32, status);
    /* update stats */
    STATS_INC(b->stats.unlock);
    if (status != BALLOON_SUCCESS) {
@@ -316,9 +341,13 @@ Backdoor_MonitorLockPagesBatched(Balloon *b,    // IN
                                  PPN64 ppn,     // IN
                                  uint32 nPages) // IN
 {
+   kprintf("%s: b:%p ppn:%lu nPages:%u\n",
+       __func__, b, ppn, nPages);
    int status = BackdoorCmd(BALLOON_BDOOR_CMD_BATCHED_LOCK,
                             (size_t)ppn, nPages, NULL, &b->resetFlag);
 
+   kprintf("%s: b:%p ppn:%lu nPages:%u status:%d\n",
+       __func__, b, ppn, nPages, status);
    /* update stats */
    STATS_INC(b->stats.lock);
    if (status != BALLOON_SUCCESS) {
@@ -352,6 +381,8 @@ Backdoor_MonitorUnlockPagesBatched(Balloon *b,          // IN
    int status = BackdoorCmd(BALLOON_BDOOR_CMD_BATCHED_UNLOCK,
                             (size_t)ppn, nPages, NULL, &b->resetFlag);
 
+   kprintf("%s: b:%p ppn:%lu nPages:%u status:%d\n",
+       __func__, b, ppn, nPages, status);
    /* update stats */
    STATS_INC(b->stats.unlock);
    if (status != BALLOON_SUCCESS) {
diff --git a/sys/gnu/dev/virtual/vmware/vmmemctl/os.c b/sys/gnu/dev/virtual/vmware/vmmemctl/os.c
index ef05699..f30227a 100644
--- a/sys/gnu/dev/virtual/vmware/vmmemctl/os.c
+++ b/sys/gnu/dev/virtual/vmware/vmmemctl/os.c
@@ -387,12 +387,15 @@ static void
 os_pmap_init(os_pmap *p) // IN
 {
    /* alloc bitmap for pages in system */
+   kprintf("1 %s: p->size:%lu p->bitmap:%p\n", __func__, p->size, p->bitmap);
    os_pmap_alloc(p);
+   kprintf("2 %s: p->size:%lu p->bitmap:%p\n", __func__, p->size, p->bitmap);
    if (!p->bitmap) {
       p->size = 0;
       p->bitmap = NULL;
       return;
    }
+   kprintf("3 %s: p->size:%lu p->bitmap:%p\n", __func__, p->size, p->bitmap);
 
    /* clear bitmap */
    bzero(p->bitmap, p->size);
@@ -509,8 +512,10 @@ os_balloonobject_delete(void)
 static void
 os_balloonobject_create(void)
 {
+   kprintf("1 %s: global_state.vmobject:%p\n", __func__, global_state.vmobject);
    global_state.vmobject = vm_object_allocate(OBJT_DEFAULT,
                   OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS));
+   kprintf("2 %s: global_state.vmobject:%p\n", __func__, global_state.vmobject);
 }
 
 
-- 
2.0.1

