vm: Separate mmap regions.
Add support for compact address layout. This feature can be enabled through the ac_layout=1 boot option. Change-Id: Ie20b808fce32b5c54d0a7e7210e0084a540e9613
This commit is contained in:
parent
48f446ecd5
commit
53398d733f
6 changed files with 53 additions and 12 deletions
|
@ -275,12 +275,12 @@ void get_parameters(kinfo_t *cbi, char *bootargs)
|
|||
mb_set_param(cbi->param_buf, BOARDVARNAME,(char *)get_board_name(machine.board_id) , cbi);
|
||||
|
||||
|
||||
/* round user stack down to leave a gap to catch kernel
|
||||
/* move user stack/data down to leave a gap to catch kernel
|
||||
* stack overflow; and to distinguish kernel and user addresses
|
||||
* at a glance (0xf.. vs 0xe..)
|
||||
*/
|
||||
cbi->user_sp &= 0xF0000000;
|
||||
cbi->user_end = cbi->user_sp;
|
||||
cbi->user_sp = USR_STACKTOP;
|
||||
cbi->user_end = USR_DATATOP;
|
||||
|
||||
/* kernel bytes without bootstrap code/data that is currently
|
||||
* still needed but will be freed after bootstrapping.
|
||||
|
|
|
@ -157,12 +157,12 @@ void get_parameters(u32_t ebx, kinfo_t *cbi)
|
|||
mb_set_param(cbi->param_buf, ARCHVARNAME, (char *)get_board_arch_name(BOARD_ID_INTEL), cbi);
|
||||
mb_set_param(cbi->param_buf, BOARDVARNAME,(char *)get_board_name(BOARD_ID_INTEL) , cbi);
|
||||
|
||||
/* round user stack down to leave a gap to catch kernel
|
||||
/* move user stack/data down to leave a gap to catch kernel
|
||||
* stack overflow; and to distinguish kernel and user addresses
|
||||
* at a glance (0xf.. vs 0xe..)
|
||||
*/
|
||||
cbi->user_sp &= 0xF0000000;
|
||||
cbi->user_end = cbi->user_sp;
|
||||
cbi->user_sp = USR_STACKTOP;
|
||||
cbi->user_end = USR_DATATOP;
|
||||
|
||||
/* kernel bytes without bootstrap code/data that is currently
|
||||
* still needed but will be freed after bootstrapping.
|
||||
|
|
|
@ -30,4 +30,25 @@
|
|||
/* for kputc() */
|
||||
#define END_OF_KMESS 0
|
||||
|
||||
/* User limits. */
|
||||
#ifndef USR_DATATOP
|
||||
#ifndef _MINIX_MAGIC
|
||||
#define USR_DATATOP 0xF0000000
|
||||
#else
|
||||
#define USR_DATATOP 0xE0000000 /* TODO: is this necessary? */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USR_STACKTOP
|
||||
#define USR_STACKTOP USR_DATATOP
|
||||
#endif
|
||||
|
||||
#ifndef USR_DATATOP_COMPACT
|
||||
#define USR_DATATOP_COMPACT USR_DATATOP
|
||||
#endif
|
||||
|
||||
#ifndef USR_STACKTOP_COMPACT
|
||||
#define USR_STACKTOP_COMPACT 0x50000000
|
||||
#endif
|
||||
|
||||
#endif /* CONST_H */
|
||||
|
|
|
@ -426,6 +426,13 @@ void cstart()
|
|||
if(!value || system_hz < 2 || system_hz > 50000) /* sanity check */
|
||||
system_hz = DEFAULT_HZ;
|
||||
|
||||
/* Get memory parameters. */
|
||||
value = env_get("ac_layout");
|
||||
if(value && atoi(value)) {
|
||||
kinfo.user_sp = (vir_bytes) USR_STACKTOP_COMPACT;
|
||||
kinfo.user_end = (vir_bytes) USR_DATATOP_COMPACT;
|
||||
}
|
||||
|
||||
DEBUGEXTRA(("cstart\n"));
|
||||
|
||||
/* Record miscellaneous information for user-space servers. */
|
||||
|
|
|
@ -75,7 +75,7 @@ static struct vir_region *mmap_region(struct vmproc *vmp, vir_bytes addr,
|
|||
|
||||
if (!vr) {
|
||||
/* No address given or address already in use. */
|
||||
vr = map_page_region(vmp, VM_PAGE_SIZE, VM_DATATOP, len,
|
||||
vr = map_page_region(vmp, VM_MMAPBASE, VM_MMAPTOP, len,
|
||||
vrflags, mfflags, mt);
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ int do_map_phys(message *m)
|
|||
if(len % VM_PAGE_SIZE)
|
||||
len += VM_PAGE_SIZE - (len % VM_PAGE_SIZE);
|
||||
|
||||
if(!(vr = map_page_region(vmp, 0, VM_DATATOP, len,
|
||||
if(!(vr = map_page_region(vmp, VM_MMAPBASE, VM_MMAPTOP, len,
|
||||
VR_DIRECT | VR_WRITABLE, 0, &mem_type_directphys))) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
@ -419,8 +419,8 @@ int do_remap(message *m)
|
|||
vr = map_page_region(dvmp, da, 0, size, flags, 0,
|
||||
&mem_type_shared);
|
||||
else
|
||||
vr = map_page_region(dvmp, 0, VM_DATATOP, size, flags, 0,
|
||||
&mem_type_shared);
|
||||
vr = map_page_region(dvmp, VM_MMAPBASE, VM_MMAPTOP, size,
|
||||
flags, 0, &mem_type_shared);
|
||||
|
||||
if(!vr) {
|
||||
printf("VM: re-map of shared area failed\n");
|
||||
|
|
|
@ -62,8 +62,21 @@
|
|||
#define NO_MEM ((phys_clicks) MAP_NONE) /* returned by alloc_mem() with mem is up */
|
||||
|
||||
/* And what is the highest addressable piece of memory? */
|
||||
#define VM_DATATOP kernel_boot_info.user_end
|
||||
#define VM_STACKTOP kernel_boot_info.user_sp
|
||||
#define VM_DATATOP kernel_boot_info.user_end
|
||||
|
||||
#define VM_STACKTOP kernel_boot_info.user_sp
|
||||
|
||||
/* Live update will work only with magic instrumentation. Live update requires
|
||||
* strict separation of regions within the process to succeed. Therefore,
|
||||
* apply this strict separation only if magic instrumentation is used.
|
||||
* Otherwise, do not place such limitations on processes.
|
||||
*/
|
||||
#ifdef _MINIX_MAGIC
|
||||
#define VM_MMAPTOP (VM_STACKTOP-DEFAULT_STACK_LIMIT)
|
||||
#define VM_MMAPBASE (VM_MMAPTOP/2)
|
||||
#else
|
||||
#define VM_MMAPTOP VM_DATATOP
|
||||
#define VM_MMAPBASE VM_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue