kernel - Adjust stack by an addition 128 in sendupcall()
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 8 Dec 2011 04:14:56 +0000 (20:14 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 8 Dec 2011 04:15:43 +0000 (20:15 -0800)
* Adjust stack by an addition 128 in sendupcall() for red-zone
  Note however that this code is currently unused, so it has no effect.

* If getmemsize() finds an overlapping region we break out of the inner
  loop so we can continue the outer loop.

Reported-by: swildner
sys/platform/pc64/x86_64/machdep.c

index 193c5c1..889a398 100644 (file)
@@ -810,7 +810,7 @@ sendupcall(struct vmupcall *vu, int morepending)
        upc_frame.rdx = regs->tf_rdx;
        upc_frame.flags = regs->tf_rflags;
        upc_frame.oldip = regs->tf_rip;
-       if (copyout(&upc_frame, (void *)(regs->tf_rsp - sizeof(upc_frame)),
+       if (copyout(&upc_frame, (void *)(regs->tf_rsp - sizeof(upc_frame) - 128),
            sizeof(upc_frame)) != 0) {
                kprintf("bad stack on upcall\n");
        } else {
@@ -818,7 +818,7 @@ sendupcall(struct vmupcall *vu, int morepending)
                regs->tf_rcx = (register_t)vu->vu_data;
                regs->tf_rdx = (register_t)lp->lwp_upcall;
                regs->tf_rip = (register_t)vu->vu_ctx;
-               regs->tf_rsp -= sizeof(upc_frame);
+               regs->tf_rsp -= sizeof(upc_frame) + 128;
        }
 }
 
@@ -1419,9 +1419,12 @@ getmemsize(caddr_t kmdp, u_int64_t first)
                                                "memory region, ignoring "
                                                "second region\n");
                                }
-                               continue;
+                               break;
                        }
                }
+               if (i <= physmap_idx)
+                       continue;
+
                Realmem += smap->length;
 
                if (smap->base == physmap[physmap_idx + 1]) {