I want to write a function in my kernel module to invalidate the physical page mapping of a virtual address. However, I don't know how to flush the tlb entry of the page of the virtual address. I try to use "flush_tlb_range" in my module code. However, it reports "implicit declaration of function ‘flush_tlb_range’".
Here is a snippet in my code
#include <linux/init.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/vmalloc.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <asm/tlb.h>
#include <asm/tlbflush.h>
u64 mypool_get_page(u64 gfn, bool write_fault, bool *writable){
u64 kvm_hva;
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma = current->mm->mmap;
unsigned int level;
pte_t *ptep;
kvm_hva = map_lookup(index);
....
//invalid kvm_hva in page table
ptep = lookup_address(kvm_hva, &level);
if (ptep) {
pte_clear(mm, kvm_hva, ptep);
flush_tlb_range(vma,kvm_hva, kvm_hva+PAGE_SIZE);
}
...
}
Here is my Makefile
mypool-objs := pool-main.o maptable.o
obj-m += mypool.o
KERNEL := /lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
modules :
$(MAKE) -C $(KERNEL) M=$(PWD) modules
.PHONEY:clean
clean :
rm -rf *.o *.ko
Can someone teach me how to invalidate tlb in kernel modules?
I also tried to use ‘flush_tlb_mm_range’. However, it also reports implicit declaration of function ‘flush_tlb_mm_range’.