From: Tormod Volden <debian.tormod@gmail.com>
authorAlan Cox <alan@linux.intel.com>
Sat, 15 Sep 2018 11:29:52 +0000 (12:29 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 15 Sep 2018 11:30:37 +0000 (12:30 +0100)
"ramtop" is an address, while "size" is a size

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
---

Kind of academic as long as all "simple" platforms have PROGBASE
at 0, but isn't it correct?

Tormod

(hand applied due to a clash)

Kernel/simple.c

index b178a35..ea66f6d 100644 (file)
@@ -41,7 +41,7 @@ int pagemap_alloc(ptptr p)
 /* FIXME: update once we have the new mm logic in place */
 int pagemap_realloc(usize_t code, usize_t size, usize_t stack)
 {
-  if (size > ramtop)
+  if (size > ramtop - PROGBASE)
     return ENOMEM;
   return 0;
 }
@@ -77,7 +77,8 @@ int swapout(ptptr p)
        blk = map * SWAP_SIZE;
        /* Write the app (and possibly the uarea etc..) to disk */
 #ifdef CONFIG_SPLIT_UDATA
-       swapwrite(SWAPDEV, blk, UDATA_SIZE, (uaddr_t)&udata, 1);
+       /* Note the page for the udata bit as it goes direct to udata */
+       swapwrite(SWAPDEV, blk, UDATA_SIZE, (uaddr_t)&udata, 0);
        swapwrite(SWAPDEV, blk + UDATA_BLKS, SWAPTOP - SWAPBASE,
                  SWAPBASE, 1);
 #else
@@ -108,7 +109,8 @@ void swapin(ptptr p, uint16_t map)
        }
 
 #ifdef CONFIG_SPLIT_UDATA
-       swapread(SWAPDEV, blk, UDATA_SIZE, (uaddr_t)&udata, 1);
+       /* Note the page for the udata bit as it goes direct to udata */
+       swapread(SWAPDEV, blk, UDATA_SIZE, (uaddr_t)&udata, 0);
        swapread(SWAPDEV, blk + UDATA_BLKS, SWAPTOP - SWAPBASE,
                 SWAPBASE, 1);
 #else