LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to raise a page fault? (https://www.linuxquestions.org/questions/linux-general-1/how-to-raise-a-page-fault-4175595134/)

Jungsik Choi 12-09-2016 01:40 PM

How to raise a page fault?
 
Hello everyone!! I have a question.

I want to generate a page fault intentionally even if the page table entry already exists.

So I cleared a _PAGE_PRESENT bit to generate a page fault.

Here's the kernel code I wrote:

Code:

pte = get_locked_pte(mm, addr, &ptl);
entry = *pte;
entry = pte_clear_flags(entry, _PAGE_PRESENT);
set_pte_at(mm, addr, pte, entry);
pte_unmap_unlock(pte, ptl);
flush_tlb_range(vma, vma->vm_start, vma->vm_end);

However, this code does not work. The page fault I intended does not occur. I want to know exactly how I can trigger a page fault.

Thank you.

sundialsvcs 12-11-2016 08:03 AM

You can't "fake the system to produce a page fault" in this way. You would certainly destroy the integrity of the kernel with such an attempt.

First of all, why do you feel the need to generate a page-fault for data which exists?


All times are GMT -5. The time now is 11:23 AM.