prepare SVM subsystem to support also other consitency modells

This commit is contained in:
Stefan Lankes 2011-08-23 07:40:20 -07:00
parent 0d74873fa9
commit 0a0452b7a1
6 changed files with 20 additions and 13 deletions

View file

@ -41,7 +41,8 @@
#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
#define _PAGE_BIT_PAT 7 /* on 4KB pages */
#define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
#define _PAGE_BIT_SVM 9 /* mark a virtual address range as used by the SVM system */
#define _PAGE_BIT_SVM_STRONG 9 /* mark a virtual address range as used by the SVM system */
#define _PAGE_BIT_SVM_LAZYRELEASE 10 /* mark a virtual address range as used by the SVM system */
/// Page is present
#define PG_PRESENT (1 << _PAGE_BIT_PRESENT)
@ -66,7 +67,9 @@
/// Pattern flag
#define PG_PAT (1 << _PAGE_BIT_PAT)
/// This virtual address range is used by SVM system as marked
#define PG_SVM (1 << _PAGE_BIT_SVM)
#define PG_SVM_STRONG (1 << _PAGE_BIT_SVM_STRONG)
/// This virtual address range is used by SVM system as marked
#define PG_SVM_LAZYRELEASE (1 << _PAGE_BIT_SVM_LAZYRELEASE)
/// This is a whole set of flags (PRESENT,RW,ACCESSED,DIRTY) for kernelspace tables
#define KERN_TABLE (PG_PRESENT|PG_RW|PG_ACCESSED|PG_DIRTY)

View file

@ -31,6 +31,9 @@ extern "C" {
#ifdef CONFIG_ROCKCREEK
#define SVM_STRONG (1 << 0)
#define SVM_LAZYRELEASE (1 << 1)
/** @brief Init routine of the SVM subsystem
*
* @return
@ -46,7 +49,7 @@ int svm_init(void);
*
* @return Pointer to the new memory range
*/
void* svmmalloc(size_t size);
void* svmmalloc(size_t sizei, uint32_t flags);
/** @brief Frees memory, which is managed by the SVM subsystem
*

View file

@ -355,9 +355,9 @@ size_t map_region(size_t viraddr, size_t phyaddr, uint32_t npages, uint32_t flag
if (flags & MAP_MPE)
pgt->entries[index] |= PG_MPE;
#endif
if (flags & MAP_SVM)
if (flags & MAP_SVM_STRONG)
#ifndef SVM_WB
pgt->entries[index] |= PG_SVM|PG_PWT;
pgt->entries[index] |= PG_SVM_STRONG|PG_PWT;
#else
pgt->entries[index] |= PG_SVM;
#endif
@ -404,9 +404,9 @@ int change_page_permissions(size_t start, size_t end, uint32_t flags)
phyaddr = pgt->entries[index2] & 0xFFFFF000;
newflags = pgt->entries[index2] & 0xFFF; // get old flags
if ((newflags & PG_SVM) && !(newflags & PG_PRESENT) && (flags & (VMA_READ|VMA_WRITE) && !(flags & VMA_NOACCESS)))
if ((newflags & PG_SVM_STRONG) && !(newflags & PG_PRESENT) && (flags & (VMA_READ|VMA_WRITE) && !(flags & VMA_NOACCESS)))
newflags |= PG_PRESENT;
else if ((newflags & PG_SVM) && (newflags & PG_PRESENT) && (flags & VMA_NOACCESS))
else if ((newflags & PG_SVM_STRONG) && (newflags & PG_PRESENT) && (flags & VMA_NOACCESS))
newflags &= ~PG_PRESENT;
// update flags
@ -636,7 +636,7 @@ static void pagefault_handler(struct state *s)
pgt = (page_table_t*) ((KERNEL_SPACE - 1024*PAGE_SIZE + index1*PAGE_SIZE) & 0xFFFFF000);
if (!pgt || !(pgt->entries[index2]))
goto default_handler;
if (pgt->entries[index2] & PG_SVM)
if (pgt->entries[index2] & PG_SVM_STRONG)
if (!svm_access_request(viraddr))
return;

View file

@ -137,11 +137,11 @@ int svm_access_request(size_t addr)
return change_page_permissions(addr, addr+PAGE_SIZE, VMA_READ|VMA_WRITE|VMA_CACHEABLE);
}
void* svmmalloc(size_t size)
void* svmmalloc(size_t size, uint32_t consitency)
{
size_t phyaddr, viraddr, i;
uint32_t flags;
uint32_t map_flags = MAP_KERNEL_SPACE|MAP_MPE|MAP_SVM;
uint32_t map_flags = MAP_KERNEL_SPACE|MAP_MPE|MAP_SVM_STRONG;
// currently, we allocate memory in page size granulation
size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);

View file

@ -48,7 +48,7 @@ extern "C" {
#ifdef CONFIG_ROCKCREEK
#define MAP_MPE (1 << 8)
#endif
#define MAP_SVM (1 << 9)
#define MAP_SVM_STRONG (1 << 9)
#define MAP_NO_ACCESS (1 << 10)
void NORETURN abort(void);

View file

@ -115,7 +115,8 @@ int mail_ping(void* arg) {
return 0;
}
#define N 1024
//#define N 1024
#define N 513
volatile static int* A[N];
volatile static int* B[N];
@ -172,7 +173,7 @@ static int svm_test(void *arg)
#endif
// allocate and initialize SVM region
A[0] = (int*) svmmalloc(3*N*N*sizeof(int));
A[0] = (int*) svmmalloc(3*N*N*sizeof(int), SVM_STRONG);
if (!my_ue)
memset((void*) A[0], 0x00, 3*N*N*sizeof(int));