From ae288941d58acbc90108f861245822664f632b63 Mon Sep 17 00:00:00 2001 From: rubberhead Date: Fri, 26 Jan 2024 01:13:49 +0000 Subject: [PATCH] Working (it seems), write remaining userspace next --- src/aarch64-linux-flush-dcache/my_shmem.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/aarch64-linux-flush-dcache/my_shmem.c b/src/aarch64-linux-flush-dcache/my_shmem.c index 325ef6d..0f232a3 100644 --- a/src/aarch64-linux-flush-dcache/my_shmem.c +++ b/src/aarch64-linux-flush-dcache/my_shmem.c @@ -1,6 +1,4 @@ // [TODO] Clean up headers... -// #include -#include "linux/atomic/atomic-long.h" #include #include "linux/gfp.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) */ - 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 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++; // Fill in allocated page entry + // Bad for performance, but guarantees to be the last page entry + // on out. vmf->page = new_page->page; _dbg_phys = page_to_phys(new_page->page); }