vm: merge i386 and arm pagetable code
This commit is contained in:
parent
b1da7fafd0
commit
3771a0833d
24 changed files with 613 additions and 1522 deletions
|
@ -1,5 +1,5 @@
|
||||||
.include <bsd.own.mk>
|
.include <bsd.own.mk>
|
||||||
|
|
||||||
#Arch-specific sources
|
#Arch-specific sources
|
||||||
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}
|
.PATH: ${.CURDIR}/arch/i386
|
||||||
SRCS+= pagetable.c #util.S
|
SRCS+= pagetable.c
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#include <machine/vm.h>
|
|
||||||
|
|
||||||
/* And what is the highest addressable piece of memory, when in paged
|
|
||||||
* mode?
|
|
||||||
*/
|
|
||||||
#define VM_DATATOP kernel_boot_info.user_end
|
|
||||||
#define VM_STACKTOP kernel_boot_info.user_sp
|
|
||||||
|
|
||||||
#define SLAB_PAGESIZE ARM_PAGE_SIZE
|
|
||||||
#define VM_PAGE_SIZE ARM_PAGE_SIZE
|
|
||||||
|
|
||||||
#define CLICKSPERPAGE (ARM_PAGE_SIZE/CLICK_SIZE)
|
|
|
@ -1,14 +0,0 @@
|
||||||
|
|
||||||
#ifndef _PAGEFAULTS_H
|
|
||||||
#define _PAGEFAULTS_H 1
|
|
||||||
|
|
||||||
#include <machine/vm.h>
|
|
||||||
|
|
||||||
#define PFERR_PROT(e) ((ARM_VM_PFE_FS(e) == ARM_VM_PFE_L1PERM) \
|
|
||||||
|| (ARM_VM_PFE_FS(e) == ARM_VM_PFE_L2PERM))
|
|
||||||
#define PFERR_NOPAGE(e) (!PFERR_PROT(e))
|
|
||||||
#define PFERR_WRITE(e) ((e) & ARM_VM_PFE_W)
|
|
||||||
#define PFERR_READ(e) (!((e) & ARM_VM_PFE_W))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,23 +7,6 @@
|
||||||
|
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
||||||
/* An ARM pagetable. */
|
|
||||||
typedef struct {
|
|
||||||
/* Directory entries in VM addr space - root of page table. */
|
|
||||||
u32_t *pt_dir; /* 16KB aligned (ARM_VM_DIR_ENTRIES) */
|
|
||||||
u32_t pt_dir_phys; /* physical address of pt_dir */
|
|
||||||
|
|
||||||
/* Pointers to page tables in VM address space. */
|
|
||||||
u32_t *pt_pt[ARM_VM_DIR_ENTRIES];
|
|
||||||
|
|
||||||
/* When looking for a hole in virtual address space, start
|
|
||||||
* looking here. This is in linear addresses, i.e.,
|
|
||||||
* not as the process sees it but the position in the page
|
|
||||||
* page table. This is just a hint.
|
|
||||||
*/
|
|
||||||
u32_t pt_virtop;
|
|
||||||
} pt_t;
|
|
||||||
|
|
||||||
/* Mapping flags. */
|
/* Mapping flags. */
|
||||||
#define PTF_WRITE ARM_VM_PTE_RW
|
#define PTF_WRITE ARM_VM_PTE_RW
|
||||||
#define PTF_READ ARM_VM_PTE_RO
|
#define PTF_READ ARM_VM_PTE_RO
|
||||||
|
@ -35,17 +18,31 @@ typedef struct {
|
||||||
#define PTF_CACHEWT ARM_VM_PTE_WT
|
#define PTF_CACHEWT ARM_VM_PTE_WT
|
||||||
#define PTF_SHARE ARM_VM_PTE_SHAREABLE
|
#define PTF_SHARE ARM_VM_PTE_SHAREABLE
|
||||||
|
|
||||||
|
#define ARCH_VM_DIR_ENTRIES ARM_VM_DIR_ENTRIES
|
||||||
|
#define ARCH_BIG_PAGE_SIZE ARM_BIG_PAGE_SIZE
|
||||||
|
#define ARCH_VM_ADDR_MASK ARM_VM_ADDR_MASK
|
||||||
|
#define ARCH_VM_PDE_MASK ARM_VM_PDE_MASK
|
||||||
|
#define ARCH_VM_PDE_PRESENT ARM_VM_PDE_PRESENT
|
||||||
|
#define ARCH_VM_PTE_PRESENT ARM_VM_PTE_PRESENT
|
||||||
|
#define ARCH_VM_PTE_USER ARM_VM_PTE_USER
|
||||||
|
#define ARCH_PAGEDIR_SIZE ARM_PAGEDIR_SIZE
|
||||||
|
#define ARCH_VM_PTE_RW ARM_VM_PTE_RW
|
||||||
|
#define ARCH_VM_BIGPAGE ARM_VM_BIGPAGE
|
||||||
|
#define ARCH_VM_PT_ENTRIES ARM_VM_PT_ENTRIES
|
||||||
|
#define ARCH_VM_PTE_RO ARM_VM_PTE_RO
|
||||||
|
|
||||||
/* For arch-specific PT routines to check if no bits outside
|
/* For arch-specific PT routines to check if no bits outside
|
||||||
* the regular flags are set.
|
* the regular flags are set.
|
||||||
*/
|
*/
|
||||||
#define PTF_ALLFLAGS (PTF_READ|PTF_WRITE|PTF_PRESENT|PTF_SUPER|PTF_USER|PTF_NOCACHE|PTF_CACHEWB|PTF_CACHEWT|PTF_SHARE)
|
#define PTF_ALLFLAGS (PTF_READ|PTF_WRITE|PTF_PRESENT|PTF_SUPER|PTF_USER|PTF_NOCACHE|PTF_CACHEWB|PTF_CACHEWT|PTF_SHARE)
|
||||||
|
|
||||||
#if SANITYCHECKS
|
#define PFERR_PROT(e) ((ARM_VM_PFE_FS(e) == ARM_VM_PFE_L1PERM) \
|
||||||
#define PT_SANE(p) { pt_sanitycheck((p), __FILE__, __LINE__); }
|
|| (ARM_VM_PFE_FS(e) == ARM_VM_PFE_L2PERM))
|
||||||
#else
|
#define PFERR_NOPAGE(e) (!PFERR_PROT(e))
|
||||||
#define PT_SANE(p)
|
#define PFERR_WRITE(e) ((e) & ARM_VM_PFE_W)
|
||||||
#endif
|
#define PFERR_READ(e) (!((e) & ARM_VM_PFE_W))
|
||||||
|
|
||||||
|
#define VM_PAGE_SIZE ARM_PAGE_SIZE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#include <machine/vm.h>
|
|
||||||
|
|
||||||
/* And what is the highest addressable piece of memory, when in paged
|
|
||||||
* mode?
|
|
||||||
*/
|
|
||||||
#define VM_DATATOP kernel_boot_info.user_end
|
|
||||||
#define VM_STACKTOP kernel_boot_info.user_sp
|
|
||||||
|
|
||||||
#define SLAB_PAGESIZE I386_PAGE_SIZE
|
|
||||||
#define VM_PAGE_SIZE I386_PAGE_SIZE
|
|
||||||
|
|
||||||
#define CLICKSPERPAGE (I386_PAGE_SIZE/CLICK_SIZE)
|
|
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
#ifndef _PAGEFAULTS_H
|
|
||||||
#define _PAGEFAULTS_H 1
|
|
||||||
|
|
||||||
#include <machine/vm.h>
|
|
||||||
|
|
||||||
#define PFERR_NOPAGE(e) (!((e) & I386_VM_PFE_P))
|
|
||||||
#define PFERR_PROT(e) (((e) & I386_VM_PFE_P))
|
|
||||||
#define PFERR_WRITE(e) ((e) & I386_VM_PFE_W)
|
|
||||||
#define PFERR_READ(e) (!((e) & I386_VM_PFE_W))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,23 +7,6 @@
|
||||||
|
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
||||||
/* An i386 pagetable. */
|
|
||||||
typedef struct {
|
|
||||||
/* Directory entries in VM addr space - root of page table. */
|
|
||||||
u32_t *pt_dir; /* page aligned (I386_VM_DIR_ENTRIES) */
|
|
||||||
u32_t pt_dir_phys; /* physical address of pt_dir */
|
|
||||||
|
|
||||||
/* Pointers to page tables in VM address space. */
|
|
||||||
u32_t *pt_pt[I386_VM_DIR_ENTRIES];
|
|
||||||
|
|
||||||
/* When looking for a hole in virtual address space, start
|
|
||||||
* looking here. This is in linear addresses, i.e.,
|
|
||||||
* not as the process sees it but the position in the page
|
|
||||||
* page table. This is just a hint.
|
|
||||||
*/
|
|
||||||
u32_t pt_virtop;
|
|
||||||
} pt_t;
|
|
||||||
|
|
||||||
/* Mapping flags. */
|
/* Mapping flags. */
|
||||||
#define PTF_WRITE I386_VM_WRITE
|
#define PTF_WRITE I386_VM_WRITE
|
||||||
#define PTF_READ I386_VM_READ
|
#define PTF_READ I386_VM_READ
|
||||||
|
@ -33,17 +16,29 @@ typedef struct {
|
||||||
#define PTF_MAPALLOC I386_VM_PTAVAIL1 /* Page allocated by pt code. */
|
#define PTF_MAPALLOC I386_VM_PTAVAIL1 /* Page allocated by pt code. */
|
||||||
#define PTF_NOCACHE (I386_VM_PWT | I386_VM_PCD)
|
#define PTF_NOCACHE (I386_VM_PWT | I386_VM_PCD)
|
||||||
|
|
||||||
|
#define ARCH_VM_DIR_ENTRIES I386_VM_DIR_ENTRIES
|
||||||
|
#define ARCH_BIG_PAGE_SIZE I386_BIG_PAGE_SIZE
|
||||||
|
#define ARCH_VM_ADDR_MASK I386_VM_ADDR_MASK
|
||||||
|
#define ARCH_VM_PAGE_PRESENT I386_VM_PRESENT
|
||||||
|
#define ARCH_VM_PDE_MASK I386_VM_PDE_MASK
|
||||||
|
#define ARCH_VM_PDE_PRESENT I386_VM_PRESENT
|
||||||
|
#define ARCH_VM_PTE_PRESENT I386_VM_PRESENT
|
||||||
|
#define ARCH_VM_PTE_USER I386_VM_USER
|
||||||
|
#define ARCH_VM_PTE_RW I386_VM_WRITE
|
||||||
|
#define ARCH_PAGEDIR_SIZE I386_PAGEDIR_SIZE
|
||||||
|
#define ARCH_VM_BIGPAGE I386_VM_BIGPAGE
|
||||||
|
#define ARCH_VM_PT_ENTRIES I386_VM_PT_ENTRIES
|
||||||
|
|
||||||
/* For arch-specific PT routines to check if no bits outside
|
/* For arch-specific PT routines to check if no bits outside
|
||||||
* the regular flags are set.
|
* the regular flags are set.
|
||||||
*/
|
*/
|
||||||
#define PTF_ALLFLAGS (PTF_READ|PTF_WRITE|PTF_PRESENT|PTF_USER|PTF_GLOBAL|PTF_NOCACHE)
|
#define PTF_ALLFLAGS (PTF_READ|PTF_WRITE|PTF_PRESENT|PTF_USER|PTF_GLOBAL|PTF_NOCACHE)
|
||||||
|
|
||||||
#if SANITYCHECKS
|
#define PFERR_NOPAGE(e) (!((e) & I386_VM_PFE_P))
|
||||||
#define PT_SANE(p) { pt_sanitycheck((p), __FILE__, __LINE__); }
|
#define PFERR_PROT(e) (((e) & I386_VM_PFE_P))
|
||||||
#else
|
#define PFERR_WRITE(e) ((e) & I386_VM_PFE_W)
|
||||||
#define PT_SANE(p)
|
#define PFERR_READ(e) (!((e) & I386_VM_PFE_W))
|
||||||
#endif
|
|
||||||
|
#define VM_PAGE_SIZE I386_PAGE_SIZE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
#include <machine/asm.h>
|
|
||||||
|
|
||||||
/**===========================================================================* */
|
|
||||||
/** i386_invlpg * */
|
|
||||||
/**===========================================================================* */
|
|
||||||
/* PUBLIC void i386_invlpg(u32_t addr) */
|
|
||||||
/* Tell the processor to invalidate a tlb entry at virtual address addr. */
|
|
||||||
ENTRY(i386_invlpg)
|
|
||||||
push %ebp
|
|
||||||
mov %esp, %ebp
|
|
||||||
push %eax
|
|
||||||
|
|
||||||
mov 8(%ebp), %eax
|
|
||||||
#ifdef __ACK__
|
|
||||||
invlpg %eax
|
|
||||||
#else
|
|
||||||
invlpg (%eax)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pop %eax
|
|
||||||
pop %ebp
|
|
||||||
ret
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "sanitycheck.h"
|
#include "sanitycheck.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "memory.h"
|
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* do_fork *
|
* do_fork *
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
#define _MAIN 1
|
#define _MAIN 1
|
||||||
#include "glo.h"
|
#include "glo.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
#include "glo.h"
|
#include "glo.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
|
|
@ -24,11 +24,8 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <pagefaults.h>
|
|
||||||
|
|
||||||
#include "glo.h"
|
#include "glo.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "memory.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <memory.h>
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
|
@ -12,8 +12,8 @@ struct phys_region;
|
||||||
#include <minix/vm.h>
|
#include <minix/vm.h>
|
||||||
#include <timers.h>
|
#include <timers.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <pagetable.h>
|
|
||||||
|
|
||||||
|
#include "pt.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#include "yielded.h"
|
#include "yielded.h"
|
||||||
|
|
||||||
|
|
29
servers/vm/pt.h
Normal file
29
servers/vm/pt.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
#ifndef _PT_H
|
||||||
|
#define _PT_H 1
|
||||||
|
|
||||||
|
#include <machine/vm.h>
|
||||||
|
|
||||||
|
#include "vm.h"
|
||||||
|
#include "pagetable.h"
|
||||||
|
|
||||||
|
/* A pagetable. */
|
||||||
|
typedef struct {
|
||||||
|
/* Directory entries in VM addr space - root of page table. */
|
||||||
|
u32_t *pt_dir; /* page aligned (ARCH_VM_DIR_ENTRIES) */
|
||||||
|
u32_t pt_dir_phys; /* physical address of pt_dir */
|
||||||
|
|
||||||
|
/* Pointers to page tables in VM address space. */
|
||||||
|
u32_t *pt_pt[ARCH_VM_DIR_ENTRIES];
|
||||||
|
|
||||||
|
/* When looking for a hole in virtual address space, start
|
||||||
|
* looking here. This is in linear addresses, i.e.,
|
||||||
|
* not as the process sees it but the position in the page
|
||||||
|
* page table. This is just a hint.
|
||||||
|
*/
|
||||||
|
u32_t pt_virtop;
|
||||||
|
} pt_t;
|
||||||
|
|
||||||
|
#define CLICKSPERPAGE (VM_PAGE_SIZE/CLICK_SIZE)
|
||||||
|
|
||||||
|
#endif
|
|
@ -17,7 +17,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <memory.h>
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
#include "glo.h"
|
#include "glo.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#if SANITYCHECKS
|
#if SANITYCHECKS
|
||||||
|
|
||||||
|
#define PT_SANE(p) { pt_sanitycheck((p), __FILE__, __LINE__); }
|
||||||
|
|
||||||
/* This macro is used in the sanity check functions, where file and
|
/* This macro is used in the sanity check functions, where file and
|
||||||
* line are function arguments.
|
* line are function arguments.
|
||||||
*/
|
*/
|
||||||
|
@ -48,6 +50,7 @@
|
||||||
#define SLABSANITYCHECK(l)
|
#define SLABSANITYCHECK(l)
|
||||||
#define SLABSANE(ptr)
|
#define SLABSANE(ptr)
|
||||||
#define MYASSERT(c)
|
#define MYASSERT(c)
|
||||||
|
#define PT_SANE(p)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MEMPROTECT
|
#if MEMPROTECT
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
|
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "glo.h"
|
#include "glo.h"
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <memory.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#define JUNKFREE 0 /* Fill freed pages with junk */
|
#define JUNKFREE 0 /* Fill freed pages with junk */
|
||||||
|
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
#include "sanitycheck.h"
|
#include "sanitycheck.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
|
@ -61,5 +60,9 @@
|
||||||
#define MAP_NONE 0xFFFFFFFE
|
#define MAP_NONE 0xFFFFFFFE
|
||||||
#define NO_MEM ((phys_clicks) MAP_NONE) /* returned by alloc_mem() with mem is up */
|
#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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#ifndef _VMPROC_H
|
#ifndef _VMPROC_H
|
||||||
#define _VMPROC_H 1
|
#define _VMPROC_H 1
|
||||||
|
|
||||||
#include <pagetable.h>
|
|
||||||
#include <minix/bitmap.h>
|
#include <minix/bitmap.h>
|
||||||
#include <machine/archtypes.h>
|
#include <machine/archtypes.h>
|
||||||
|
|
||||||
|
#include "pt.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#include "physravl.h"
|
#include "physravl.h"
|
||||||
#include "yieldedavl.h"
|
#include "yieldedavl.h"
|
||||||
|
|
Loading…
Reference in a new issue