Add proc_global_info (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 29 Feb 2016 18:38:35 +0000 (13:38 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 29 Feb 2016 18:38:35 +0000 (13:38 -0500)
This is a read-only, shared-memory region mapped into every process's
address space.

Rebuild the world.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/pmap64.c
kern/arch/x86/ros/mmu64.h
kern/include/ros/memlayout.h
kern/include/ros/procinfo.h
kern/src/env.c
kern/src/init.c

index 2b9fb8f..5239734 100644 (file)
@@ -434,12 +434,13 @@ static void check_syms_va(void)
        check_sym_va(KERNBASE,       0xffff800000000000);
        check_sym_va(ULIM,           0x0000800000000000);
        check_sym_va(UVPT,           0x00007f8000000000);
-       check_sym_va(UINFO,          0x00007f7fffe00000);
-       check_sym_va(UWLIM,          0x00007f7fffe00000);
-       check_sym_va(UDATA,          0x00007f7fffc00000);
-       check_sym_va(UGDATA,         0x00007f7fffbff000);
-       check_sym_va(UMAPTOP,        0x00007f7fffbff000);
-       check_sym_va(USTACKTOP,      0x00007f7fffbff000);
+       check_sym_va(UGINFO,         0x00007f7fffe00000);
+       check_sym_va(UINFO,          0x00007f7fffc00000);
+       check_sym_va(UWLIM,          0x00007f7fffc00000);
+       check_sym_va(UDATA,          0x00007f7fffa00000);
+       check_sym_va(UGDATA,         0x00007f7fff9ff000);
+       check_sym_va(UMAPTOP,        0x00007f7fff9ff000);
+       check_sym_va(USTACKTOP,      0x00007f7fff9ff000);
        check_sym_va(BRK_END,        0x0000400000000000);
 }
 
index 3ebd79e..6018fc4 100644 (file)
@@ -85,22 +85,27 @@ typedef struct x86_pgdir {
  *    UVPT      ---->  +------------------------------+ 0x00007f8000000000 -+
  *                     | Unmapped (expandable region) |                     |
  *                     |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|                     |
+ *                     |       Global R/O Info        | R-/R-  PML2_PTE_REACH
+ *                     |       (proc_glb_info)        |                     |
+ *    UGINFO    ---->  +------------------------------+ 0x00007f7fffe00000 -+
+ *                     | Unmapped (expandable region) |                     |
+ *                     |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|                     |
  *                     |     Per-Process R/O Info     | R-/R-  PML2_PTE_REACH
  *                     |         (procinfo)           |                     |
- * UWLIM, UINFO ---->  +------------------------------+ 0x00007f7fffe00000 -+
+ * UWLIM, UINFO ---->  +------------------------------+ 0x00007f7fffc00000 -+
  *                     | Unmapped (expandable region) |                     |
  *                     |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|                     |
  *                     |     Per-Process R/W Data     | RW/RW  PML2_PTE_REACH
  *                     |         (procdata)           |                     |
- *    UDATA     ---->  +------------------------------+ 0x00007f7fffc00000 -+
+ *    UDATA     ---->  +------------------------------+ 0x00007f7fffa00000 -+
  *                     |                              |
  *                     |    Global Shared R/W Data    | RW/RW  PGSIZE
  *                     |                              |
- * UMAPTOP, UGDATA ->  +------------------------------+ 0x00007f7fffbff000
+ * UMAPTOP, UGDATA ->  +------------------------------+ 0x00007f7fff9ff000
  *    USTACKTOP        |                              |
  *                     |      Normal User Stack       | RW/RW 256 * PGSIZE
  *                     |                              |
- *                     +------------------------------+ 0x00007f7fffaff000
+ *                     +------------------------------+ 0x00007f7fff8ff000
  *                     |                              |
  *                     |        Empty Memory          |
  *                     |                              |
index 9920429..934646f 100644 (file)
 #define EXTPHYSMEM     0x100000
 #endif
 
+/* Read-only, global shared info structures */
+#define UGINFO                 (UVPT - PTSIZE)
 /* Read-only, per-process shared info structures */
-#define UINFO                  (UVPT - PTSIZE)
+#define UINFO                  (UGINFO - PTSIZE)
 /* Top of user-writable VM */
 #define UWLIM                  UINFO
 /* Read-write, per-process shared info structures */
index 2cd784e..53d5b6f 100644 (file)
@@ -61,12 +61,23 @@ typedef struct procinfo {
        struct pcore            pcoremap[MAX_NUM_CORES];
        seq_ctr_t                       coremap_seqctr;
 } procinfo_t;
-#define PROCINFO_NUM_PAGES  ((sizeof(procinfo_t)-1)/PGSIZE + 1)        
+#define PROCINFO_NUM_PAGES  ((sizeof(procinfo_t)-1)/PGSIZE + 1)
 
+/* We align this so that the kernel can easily allocate it in the BSS */
+struct proc_global_info {
 
-// this is how user programs access the procinfo page
-#ifndef ROS_KERNEL
-# define __procinfo (*(procinfo_t*)UINFO)
+} __attribute__((aligned(PGSIZE)));
+#define PROCGINFO_NUM_PAGES  (sizeof(struct proc_global_info) / PGSIZE)
+
+#ifdef ROS_KERNEL
+
+/* defined in init.c */
+extern struct proc_global_info __proc_global_info;
+
+#else /* Userland */
+
+#define __procinfo (*(procinfo_t*)UINFO)
+#define __proc_global_info (*(struct proc_global_info*)UGINFO)
 
 #include <ros/common.h>
 #include <ros/atomic.h>
index f2c49c1..6d2811a 100644 (file)
@@ -61,6 +61,12 @@ int env_setup_vm(env_t *e)
                                PGSIZE), (void*)(UDATA + i*PGSIZE), PTE_USER_RW) < 0)
                        goto env_setup_vm_error;
        }
+       for (int i = 0; i < PROCGINFO_NUM_PAGES; i++) {
+               if (page_insert(e->env_pgdir,
+                               kva2page((void*)&__proc_global_info + i * PGSIZE),
+                               (void*)(UGINFO + i * PGSIZE), PTE_USER_RO) < 0)
+                       goto env_setup_vm_error;
+       }
        /* Finally, set up the Global Shared Data page for all processes.  Can't be
         * trusted, but still very useful at this stage for us.  Consider removing
         * when we have real processes (TODO). 
index a6a0553..e75a80d 100644 (file)
@@ -58,6 +58,7 @@
        } while (0)
 
 int booting = 1;
+struct proc_global_info __proc_global_info;
 struct sysinfo_t sysinfo;
 static char boot_cmdline[MAX_BOOT_CMDLINE_SIZE];