Working (it seems), write remaining userspace next

This commit is contained in:
Zhengyi Chen 2024-01-26 01:13:49 +00:00
parent 20891fd58e
commit ae288941d5

View file

@ -1,6 +1,4 @@
// [TODO] Clean up headers... // [TODO] Clean up headers...
// #include <asm/cacheflush.h>
#include "linux/atomic/atomic-long.h"
#include <linux/device.h> #include <linux/device.h>
#include "linux/gfp.h" #include "linux/gfp.h"
#include "linux/mutex.h" #include "linux/mutex.h"
@ -100,7 +98,11 @@ static vm_fault_t my_shmem_vmops_fault(struct vm_fault *vmf)
} }
/* Otherwise, allocate the new page(s) */ /* Otherwise, allocate the new page(s) */
for (int i = 0; i <= nr_pages_from_vm_start - my_shmem_page_count; i++) ulong nr_pages_to_alloc =
nr_pages_from_vm_start - my_shmem_page_count + 1;
pr_info("[%s] Not enough remappable pages, allocating %ld more...\n",
__func__, nr_pages_to_alloc);
for (; nr_pages_to_alloc > 0; nr_pages_to_alloc--)
{ {
// Allocate page handle in kernel // Allocate page handle in kernel
struct my_shmem_page *new_page = kzalloc( struct my_shmem_page *new_page = kzalloc(
@ -125,6 +127,8 @@ static vm_fault_t my_shmem_vmops_fault(struct vm_fault *vmf)
my_shmem_page_count++; my_shmem_page_count++;
// Fill in allocated page entry // Fill in allocated page entry
// Bad for performance, but guarantees to be the last page entry
// on out.
vmf->page = new_page->page; vmf->page = new_page->page;
_dbg_phys = page_to_phys(new_page->page); _dbg_phys = page_to_phys(new_page->page);
} }