arm:vm allow per memory type flags.
Change-Id: Id5a5bd479bdfbbc3fb52a85c29e1d7712a1171a7
This commit is contained in:
		
							parent
							
								
									34b517ab12
								
							
						
					
					
						commit
						73ed75a454
					
				@ -29,6 +29,7 @@ static int anon_writable(struct phys_region *pr);
 | 
			
		||||
static int anon_resize(struct vmproc *vmp, struct vir_region *vr, vir_bytes l);
 | 
			
		||||
static u32_t anon_regionid(struct vir_region *region);
 | 
			
		||||
static int anon_refcount(struct vir_region *vr);
 | 
			
		||||
static int anon_pt_flags(struct vir_region *vr);
 | 
			
		||||
 | 
			
		||||
struct mem_type mem_type_anon = {
 | 
			
		||||
	.name = "anonymous memory",
 | 
			
		||||
@ -40,9 +41,18 @@ struct mem_type mem_type_anon = {
 | 
			
		||||
	.ev_split = anon_split,
 | 
			
		||||
	.regionid = anon_regionid,
 | 
			
		||||
	.writable = anon_writable,
 | 
			
		||||
	.refcount = anon_refcount
 | 
			
		||||
	.refcount = anon_refcount,
 | 
			
		||||
	.pt_flags = anon_pt_flags,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int anon_pt_flags(struct vir_region *vr){
 | 
			
		||||
#if defined(__arm__)
 | 
			
		||||
	return ARM_VM_PTE_CACHED;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int anon_unreference(struct phys_region *pr)
 | 
			
		||||
{
 | 
			
		||||
	assert(pr->ph->refcount == 0);
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,7 @@ static int anon_contig_sanitycheck(struct phys_region *pr, char *file, int line)
 | 
			
		||||
static int anon_contig_writable(struct phys_region *pr);
 | 
			
		||||
static int anon_contig_resize(struct vmproc *vmp, struct vir_region *vr, vir_bytes l);
 | 
			
		||||
static int anon_contig_new(struct vir_region *vr);
 | 
			
		||||
static int anon_contig_pt_flags(struct vir_region *vr);
 | 
			
		||||
 | 
			
		||||
struct mem_type mem_type_anon_contig = {
 | 
			
		||||
	.name = "anonymous memory (physically contiguous)",
 | 
			
		||||
@ -26,9 +27,18 @@ struct mem_type mem_type_anon_contig = {
 | 
			
		||||
	.ev_pagefault = anon_contig_pagefault,
 | 
			
		||||
	.ev_resize = anon_contig_resize,
 | 
			
		||||
	.ev_sanitycheck = anon_contig_sanitycheck,
 | 
			
		||||
	.writable = anon_contig_writable
 | 
			
		||||
	.writable = anon_contig_writable,
 | 
			
		||||
	.pt_flags = anon_contig_pt_flags,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int anon_contig_pt_flags(struct vir_region *vr){
 | 
			
		||||
#if defined(__arm__)
 | 
			
		||||
	return  ARM_VM_PTE_DEVICE;
 | 
			
		||||
#else
 | 
			
		||||
	return  0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int anon_contig_pagefault(struct vmproc *vmp, struct vir_region *region,
 | 
			
		||||
	struct phys_region *ph, int write, vfs_callback_t cb, void *state,
 | 
			
		||||
	int len, int *io)
 | 
			
		||||
 | 
			
		||||
@ -31,6 +31,7 @@ static int cache_resize(struct vmproc *vmp, struct vir_region *vr, vir_bytes l);
 | 
			
		||||
static int cache_pagefault(struct vmproc *vmp, struct vir_region *region, 
 | 
			
		||||
        struct phys_region *ph, int write, vfs_callback_t cb, void *state,
 | 
			
		||||
	int len, int *io);
 | 
			
		||||
static int cache_pt_flags(struct vir_region *vr);
 | 
			
		||||
 | 
			
		||||
struct mem_type mem_type_cache = {
 | 
			
		||||
	.name = "cache memory",
 | 
			
		||||
@ -40,8 +41,18 @@ struct mem_type mem_type_cache = {
 | 
			
		||||
	.ev_sanitycheck = cache_sanitycheck,
 | 
			
		||||
	.ev_pagefault = cache_pagefault,
 | 
			
		||||
	.writable = cache_writable,
 | 
			
		||||
	.pt_flags = cache_pt_flags,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int cache_pt_flags(struct vir_region *vr){
 | 
			
		||||
#if defined(__arm__)
 | 
			
		||||
	return ARM_VM_PTE_CACHED;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int cache_reference(struct phys_region *pr, struct phys_region *pr2)
 | 
			
		||||
{
 | 
			
		||||
	return OK;
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,8 @@
 | 
			
		||||
 | 
			
		||||
#include "vm.h"
 | 
			
		||||
#include "proto.h"
 | 
			
		||||
#include "region.h"
 | 
			
		||||
#include "glo.h"
 | 
			
		||||
 | 
			
		||||
/* These functions are static so as to not pollute the
 | 
			
		||||
 * global namespace, and are accessed through their function
 | 
			
		||||
@ -21,15 +23,25 @@ static int phys_pagefault(struct vmproc *vmp, struct vir_region *region,
 | 
			
		||||
        struct phys_region *ph, int write, vfs_callback_t cb, void *state,
 | 
			
		||||
	int len, int *io);
 | 
			
		||||
static int phys_copy(struct vir_region *vr, struct vir_region *newvr);
 | 
			
		||||
static int phys_pt_flags(struct vir_region *vr);
 | 
			
		||||
 | 
			
		||||
struct mem_type mem_type_directphys = {
 | 
			
		||||
	.name = "physical memory mapping",
 | 
			
		||||
	.ev_copy = phys_copy,
 | 
			
		||||
	.ev_unreference = phys_unreference,
 | 
			
		||||
	.writable = phys_writable,
 | 
			
		||||
	.ev_pagefault = phys_pagefault
 | 
			
		||||
	.ev_pagefault = phys_pagefault,
 | 
			
		||||
	.pt_flags = phys_pt_flags
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int phys_pt_flags(struct vir_region *vr){
 | 
			
		||||
#if defined(__arm__)
 | 
			
		||||
	return ARM_VM_PTE_DEVICE;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int phys_unreference(struct phys_region *pr)
 | 
			
		||||
{
 | 
			
		||||
	return OK;
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,7 @@ static int mappedfile_writable(struct phys_region *pr);
 | 
			
		||||
static int mappedfile_copy(struct vir_region *vr, struct vir_region *newvr);
 | 
			
		||||
static int mappedfile_lowshrink(struct vir_region *vr, vir_bytes len);
 | 
			
		||||
static void mappedfile_delete(struct vir_region *region);
 | 
			
		||||
static int mappedfile_pt_flags(struct vir_region *vr);
 | 
			
		||||
 | 
			
		||||
struct mem_type mem_type_mappedfile = {
 | 
			
		||||
	.name = "file-mapped memory",
 | 
			
		||||
@ -36,8 +37,17 @@ struct mem_type mem_type_mappedfile = {
 | 
			
		||||
	.ev_split = mappedfile_split,
 | 
			
		||||
	.ev_lowshrink = mappedfile_lowshrink,
 | 
			
		||||
	.ev_delete = mappedfile_delete,
 | 
			
		||||
	.pt_flags = mappedfile_pt_flags,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int mappedfile_pt_flags(struct vir_region *vr){
 | 
			
		||||
#if defined(__arm__)
 | 
			
		||||
	return ARM_VM_PTE_CACHED;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int mappedfile_unreference(struct phys_region *pr)
 | 
			
		||||
{
 | 
			
		||||
	assert(pr->ph->refcount == 0);
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,7 @@ static void shared_delete(struct vir_region *region);
 | 
			
		||||
static u32_t shared_regionid(struct vir_region *region);
 | 
			
		||||
static int shared_copy(struct vir_region *vr, struct vir_region *newvr);
 | 
			
		||||
static int shared_refcount(struct vir_region *vr);
 | 
			
		||||
static int shared_pt_flags(struct vir_region *vr);
 | 
			
		||||
 | 
			
		||||
struct mem_type mem_type_shared = {
 | 
			
		||||
	.name = "shared memory",
 | 
			
		||||
@ -33,9 +34,18 @@ struct mem_type mem_type_shared = {
 | 
			
		||||
	.ev_delete = shared_delete,
 | 
			
		||||
	.regionid = shared_regionid,
 | 
			
		||||
	.refcount = shared_refcount,
 | 
			
		||||
	.writable = shared_writable
 | 
			
		||||
	.writable = shared_writable,
 | 
			
		||||
	.pt_flags = shared_pt_flags,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int shared_pt_flags(struct vir_region *vr){
 | 
			
		||||
#if defined(__arm__)
 | 
			
		||||
	return ARM_VM_PTE_CACHED;
 | 
			
		||||
#else
 | 
			
		||||
	return 0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int shared_unreference(struct phys_region *pr)
 | 
			
		||||
{
 | 
			
		||||
	return mem_type_anon.ev_unreference(pr);
 | 
			
		||||
 | 
			
		||||
@ -27,6 +27,7 @@ typedef struct mem_type {
 | 
			
		||||
        int (*ev_lowshrink)(struct vir_region *vr, vir_bytes len);
 | 
			
		||||
	u32_t (*regionid)(struct vir_region *vr);
 | 
			
		||||
        int (*refcount)(struct vir_region *vr);
 | 
			
		||||
        int (*pt_flags)(struct vir_region *vr); /* page table flags */
 | 
			
		||||
} mem_type_t;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -273,13 +273,9 @@ int map_ph_writept(struct vmproc *vmp, struct vir_region *vr,
 | 
			
		||||
	else
 | 
			
		||||
		flags |= PTF_READ;
 | 
			
		||||
 | 
			
		||||
#if  defined(__arm__)
 | 
			
		||||
	if (pb->phys >= 0x80000000 && pb->phys < (0xc0000000 - VM_PAGE_SIZE)) {
 | 
			
		||||
		// LSC Do this only for actual RAM
 | 
			
		||||
		// KEJO:fishy will need to look into this 
 | 
			
		||||
		flags |= ARM_VM_PTE_DEVICE;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if(vr->def_memtype->pt_flags)
 | 
			
		||||
		flags |= vr->def_memtype->pt_flags(vr);
 | 
			
		||||
 | 
			
		||||
	if(pt_writemap(vmp, &vmp->vm_pt, vr->vaddr + pr->offset,
 | 
			
		||||
			pb->phys, VM_PAGE_SIZE, flags,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user