From bb107c4e29877ab7be19fbe8c52eef01d44b03cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 22 May 2008 11:59:47 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20by=20Jan=20Kl=C3=B6tzke:=20*=20In=20vm8?= =?UTF-8?q?6=20mode=20CS=20will=20have=20arbitrary=20values=20so=20we=20ch?= =?UTF-8?q?eck=20for=20both=20USER=5FCODE=5FSEG=20=20=20and=20the=20VM=20f?= =?UTF-8?q?lag=20in=20EFLAGS.=20This=20is=20also=20done=20when=20entering?= =?UTF-8?q?=20interrupt=20gates.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25607 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/arch/x86/arch_cpu.h | 4 ++++ src/system/kernel/arch/x86/arch_int.c | 2 +- src/system/kernel/arch/x86/arch_thread.cpp | 2 +- src/system/kernel/arch/x86/arch_user_debugger.cpp | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/headers/private/kernel/arch/x86/arch_cpu.h b/headers/private/kernel/arch/x86/arch_cpu.h index 803edc6816..11e412f52c 100644 --- a/headers/private/kernel/arch/x86/arch_cpu.h +++ b/headers/private/kernel/arch/x86/arch_cpu.h @@ -157,6 +157,10 @@ struct iframe { uint32 user_ss; }; +#define IFRAME_IS_USER(f) ( ((f)->cs == USER_CODE_SEG) \ + || (((f)->flags & 0x20000) != 0 )) +#define IFRAME_IS_VM86(f) ( ((f)->flags & 0x20000) != 0 ) + // features enum x86_feature_type { FEATURE_COMMON = 0, // cpuid eax=1, ecx register diff --git a/src/system/kernel/arch/x86/arch_int.c b/src/system/kernel/arch/x86/arch_int.c index c612ec6960..4d2b4720bb 100644 --- a/src/system/kernel/arch/x86/arch_int.c +++ b/src/system/kernel/arch/x86/arch_int.c @@ -401,7 +401,7 @@ unexpected_exception(struct iframe* frame) return; } - if (frame->cs == USER_CODE_SEG) { + if (IFRAME_IS_USER(frame)) { enable_interrupts(); if (user_debug_exception_occurred(type, signal)) diff --git a/src/system/kernel/arch/x86/arch_thread.cpp b/src/system/kernel/arch/x86/arch_thread.cpp index 9674117d3c..4de532a1f8 100644 --- a/src/system/kernel/arch/x86/arch_thread.cpp +++ b/src/system/kernel/arch/x86/arch_thread.cpp @@ -143,7 +143,7 @@ i386_get_user_iframe(void) struct iframe* frame = get_current_iframe(); while (frame != NULL) { - if (frame->cs == USER_CODE_SEG) + if (IFRAME_IS_USER(frame)) return frame; frame = get_previous_iframe(frame); } diff --git a/src/system/kernel/arch/x86/arch_user_debugger.cpp b/src/system/kernel/arch/x86/arch_user_debugger.cpp index 66ec93a7b2..7d9b70f05f 100644 --- a/src/system/kernel/arch/x86/arch_user_debugger.cpp +++ b/src/system/kernel/arch/x86/arch_user_debugger.cpp @@ -778,7 +778,7 @@ x86_handle_debug_exception(struct iframe *frame) TRACE(("i386_handle_debug_exception(): DR6: %lx, DR7: %lx\n", dr6, dr7)); - if (frame->cs != USER_CODE_SEG) { + if (!IFRAME_IS_USER(frame)) { panic("debug exception in kernel mode: dr6: 0x%lx, dr7: 0x%lx", dr6, dr7); return; @@ -850,7 +850,7 @@ x86_handle_breakpoint_exception(struct iframe *frame) { TRACE(("i386_handle_breakpoint_exception()\n")); - if (frame->cs != USER_CODE_SEG) { + if (!IFRAME_IS_USER(frame)) { panic("breakpoint exception in kernel mode"); return; }