From 8c005190c455f3722c64a6ffc7dece9020da7258 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 6 Apr 2018 21:33:10 +0200 Subject: [PATCH] kernel: Determine kernel vs. user page fault depending on iframe. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The action vm_page_fault takes should depend on whether the iframe to be handled is a user iframe or not. The check for the user flag in the error code does however only check if the fault happend in user or kernel space. Use IFRAME_IS_USER() instead which checks the privilege level of the iframe. Under 32 bit x86 this also handles vm86 compatibility mode properly. This is the same logic as used on FreeBSD (TRAPF_USERMODE). Fixes #13930. Change-Id: I9c348b6ab4c60daaaaa2c0fe33bcc3336aa29f7b Reviewed-on: https://review.haiku-os.org/560 Reviewed-by: Axel Dörfler --- src/system/kernel/arch/x86/arch_int.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index fe23614d48..1771dcc4ce 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -349,7 +349,7 @@ x86_page_fault_exception(struct iframe* frame) vm_page_fault(cr2, frame->ip, (frame->error_code & PGFAULT_W) != 0, // write access (frame->error_code & PGFAULT_I) != 0, // instruction fetch - (frame->error_code & PGFAULT_U) != 0, // userland + IFRAME_IS_USER(frame), // userland &newip); if (newip != 0) { // the page fault handler wants us to modify the iframe to set the