$OpenBSD: patch-hotspot_src_os_cpu_bsd_x86_vm_os_bsd_x86_cpp,v 1.1 2013/03/19 19:26:45 kurt Exp $
--- hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp.orig	Mon Feb  4 13:08:55 2013
+++ hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Mon Feb  4 22:00:10 2013
@@ -226,7 +226,6 @@
 #  define context_esi sc_esi
 #  define context_edi sc_edi
 #  define context_eflags sc_eflags
-#  define context_trapno sc_trapno
 # endif
 #endif
 
@@ -394,6 +393,9 @@ frame os::current_frame() {
 
 // From IA32 System Programming Guide
 enum {
+#ifdef __OpenBSD__
+  trap_protection_fault = 0x4,
+#endif
   trap_page_fault = 0xE
 };
 
@@ -649,7 +651,11 @@ JVM_handle_bsd_signal(int sig,
   // Furthermore, a false-positive should be harmless.
   if (UnguardOnExecutionViolation > 0 &&
       (sig == SIGSEGV || sig == SIGBUS) &&
+#ifdef __OpenBSD__
+      uc->context_trapno == trap_protection_fault) {
+#else
       uc->context_trapno == trap_page_fault) {
+#endif
     int page_size = os::vm_page_size();
     address addr = (address) info->si_addr;
     address pc = os::Bsd::ucontext_get_pc(uc);
@@ -1062,6 +1068,7 @@ void os::print_context(outputStream *st, void *context
   st->cr();
   st->print(  "EIP=" INTPTR_FORMAT, uc->context_eip);
   st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_eflags);
+  st->print(", TRAPNO=" INTPTR_FORMAT, uc->context_trapno);
 #endif // AMD64
   st->cr();
   st->cr();
