Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6502

Write to CR2 during PageFault ISR

$
0
0

I'm writing a pagefault handler, and I'm wondering what happens if the ISR changes the value of cr2 right before the ISR returns.

For example, if some code does this:

mov    rax,QWORD PTR [rip+0x23]mov    rbx,QWORD PTR [rax+0x28432] movabs rax,0xdeadbeefdeadbeefmov    rcx,QWORD PTR [rax]

Let's say [rax+0x28432] has the Present bit in the PTE set to 0. Let's also assume that the 0xdeadbeefdeadbeef points to valid, but paged-out memory.

Assuming the code is the ISR (This is pseudocode):

PPTE pte = GetPteFromVA(__readcr2() & ~0xFFF);/* Bring page into memory */pte->Present = 1;__writecr2(newValue);__asm{    add rsp, 8    iretq}

What will happen back in the code? Will the instruction that loads rbx with a value use the updated cr2 value in its computation? What will happen when trying to load rcx with the value that rax is pointing to? Is cr2 only used for notifying the kernel of a faulting address? Or will something break?


Viewing all articles
Browse latest Browse all 6502

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>