Cherry (cherry@) has been mostly working with the amd64 when it came to MD
part of the code. This is perfectly fine, but since my initial foray into NetBSD
was mostly with i386 variant of the Kernel, since my Virtual Machine did not
have the resources to run a 64 bit machine at that point in time.

After a day of doing merging the code base between myself and Cherry, I had do a
compile to see if the new code that came in was breaking the build. This is when
I came across the MD part of the changes.

The amd64 build was working in Cherry’s machine and obviously since I lacked
the changes in i386 which was causing the build to break. After some careful
diff-ing I was able to find the necessary changes from the amd64 files and the
changes were confined to a single file, sys/arch/i386/i386/machdep.c

Here is the total changes done in a diff.
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index c8a4c41..11bf5c8 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1027,56 +1027,29 @@ static void
 init386_msgbuf(void)
 {
/* Message buffer is located at end of core. */
-       struct vm_physseg *vps;
-       psize_t sz = round_page(MSGBUFSIZE);
-       psize_t reqsz = sz;
-       unsigned int x;
-
- search_again:
-       vps = NULL;
-       for (x = 0; x < vm_nphysseg; ++x) {
-               vps = VM_PHYSMEM_PTR(x);
-               if (ctob(vps->avail_end) == avail_end) {
-                       break;
-               }
-       }
-       if (x == vm_nphysseg)
-               panic("init386: can't find end of memory");
+       psize_t reqsz = round_page(MSGBUFSIZE);
+       psize_t sz = 0;

-       /* Shrink so it'll fit in the last segment. */
-       if (vps->avail_end - vps->avail_start < atop(sz))
-               sz = ctob(vps->avail_end - vps->avail_start);
+       for (sz = 0; sz < reqsz; sz += PAGE_SIZE) {
+               paddr_t stolenpa;

-       vps->avail_end -= atop(sz);
-       vps->end -= atop(sz);
-       msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
-       msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(vps->avail_end);
+               if (!uvm_page_physget(&stolenpa))
+                       break;

-       /* Remove the last segment if it now has no pages. */
-       if (vps->start == vps->end) {
-               for (--vm_nphysseg; x < vm_nphysseg; x++)
-                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
+               if (stolenpa == (msgbuf_p_seg[msgbuf_p_cnt].paddr
+                       + PAGE_SIZE)) {
+                       /* contiguous: append it to current buf alloc */
+                       msgbuf_p_seg[msgbuf_p_cnt].sz += PAGE_SIZE;
+               } else  {
+                       /* non-contiguous: start a new msgbuf seg */
+                       msgbuf_p_seg[msgbuf_p_cnt].sz = PAGE_SIZE;
+                       msgbuf_p_seg[msgbuf_p_cnt++].paddr = stolenpa;
                }
-
-       /* Now find where the new avail_end is. */
-       for (avail_end = 0, x = 0; x < vm_nphysseg; x++)
-               if (VM_PHYSMEM_PTR(x)->avail_end > avail_end)
-                       avail_end = VM_PHYSMEM_PTR(x)->avail_end;
-       avail_end = ctob(avail_end);
-
-       if (sz == reqsz)
-               return;
-
-       reqsz -= sz;
-       if (msgbuf_p_cnt == VM_PHYSSEG_MAX) {
-               /* No more segments available, bail out. */
-               printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n",
-                   (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz));
-               return;
        }

-       sz = reqsz;
-       goto search_again;
+       if (sz != reqsz)
+               printf("%s: could only allocate %ld bytes of requested %ld bytes\n",
+                   __func__, sz, reqsz);
 }

 #ifndef XEN

Even though I mostly copy-pasted the code originally written by Cherry, I was
able to appreciate and understand the upcoming changes for the uvm_physseg
changes that was being brought into the uvm system.