Skip to content

Commit

Permalink
Add segfault_was_write to cpu_state
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Dec 21, 2020
1 parent f2976b7 commit 1e06d8d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions emu/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ struct cpu_state {

// for the page fault handler
addr_t segfault_addr;
bool segfault_was_write;

dword_t trapno;
};
Expand Down
1 change: 1 addition & 0 deletions jit/gadgets-x86_64/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jit_exit:
movl (%_ip), %_tmp
movl 8(%_ip), %_eip
movl %_eip, CPU_segfault_addr(%_cpu)
movb $0, CPU_segfault_was_write(%_cpu)
jmp jit_exit

.gadget exit
Expand Down
5 changes: 5 additions & 0 deletions jit/gadgets-x86_64/memory.S
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@

segfault_\type:
movl %_addr, CPU_segfault_addr(%_cpu)
.ifc \type,read
movb $0, CPU_segfault_was_write(%_cpu)
.else
movb $1, CPU_segfault_was_write(%_cpu)
.endif
movl (%_ip), %_eip
movl $INT_GPF, %_tmp
jmp jit_exit
Expand Down
1 change: 1 addition & 0 deletions jit/offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void cpu() {
OFFSET(LOCAL, jit_frame, last_block);
OFFSET(LOCAL, jit_frame, ret_cache);
OFFSET(CPU, cpu_state, segfault_addr);
OFFSET(CPU, cpu_state, segfault_was_write);
MACRO(MEM_READ);
MACRO(MEM_WRITE);

Expand Down

0 comments on commit 1e06d8d

Please sign in to comment.