# HG changeset patch # User mbaesken # Date 1558617301 -7200 # Thu May 23 15:15:01 2019 +0200 # Node ID cae1dfe904ecb33c92089ebf57be682d234ab3b1 # Parent c08a6838c3c4c9957d5efcfbca1a4691c5111433 8224221: add memprotect calls to event log Reviewed-by: dholmes, mdoerr diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -2452,6 +2452,7 @@ // // See http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mprotect.htm + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot); bool rc = ::mprotect(addr, size, prot) == 0 ? true : false; if (!rc) { @@ -2492,6 +2493,7 @@ // A valid strategy is just to try again. This usually works. :-/ ::usleep(1000); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot); if (::mprotect(addr, size, prot) == 0) { const bool read_protected_2 = (SafeFetch32((int*)addr, 0x12345678) == 0x12345678 && diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -1956,6 +1956,7 @@ int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; #ifdef __OpenBSD__ // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot); if (::mprotect(addr, size, prot) == 0) { return true; } @@ -2040,6 +2041,7 @@ bool os::pd_uncommit_memory(char* addr, size_t size) { #ifdef __OpenBSD__ // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size)); return ::mprotect(addr, size, PROT_NONE) == 0; #else uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE, @@ -2108,6 +2110,7 @@ assert(addr == bottom, "sanity check"); size = align_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size()); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot); return ::mprotect(bottom, size, prot) == 0; } diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -3483,6 +3483,7 @@ assert(addr == bottom, "sanity check"); size = align_up(pointer_delta(addr, bottom, 1) + size, os::Linux::page_size()); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot); return ::mprotect(bottom, size, prot) == 0; } diff --git a/src/hotspot/os/solaris/os_solaris.cpp b/src/hotspot/os/solaris/os_solaris.cpp --- a/src/hotspot/os/solaris/os_solaris.cpp +++ b/src/hotspot/os/solaris/os_solaris.cpp @@ -2704,6 +2704,7 @@ static bool solaris_mprotect(char* addr, size_t bytes, int prot) { assert(addr == (char*)align_down((uintptr_t)addr, os::vm_page_size()), "addr must be page aligned"); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+bytes), prot); int retVal = mprotect(addr, bytes, prot); return retVal == 0; } @@ -4304,6 +4305,7 @@ // Mark the polling page as unreadable void os::make_polling_page_unreadable(void) { + Events::log(NULL, "Protecting polling page " INTPTR_FORMAT " with PROT_NONE", p2i(_polling_page)); if (mprotect((char *)_polling_page, page_size, PROT_NONE) != 0) { fatal("Could not disable polling page"); } @@ -4311,6 +4313,7 @@ // Mark the polling page as readable void os::make_polling_page_readable(void) { + Events::log(NULL, "Protecting polling page " INTPTR_FORMAT " with PROT_READ", p2i(_polling_page)); if (mprotect((char *)_polling_page, page_size, PROT_READ) != 0) { fatal("Could not enable polling page"); } diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -542,7 +542,7 @@ diagnostic(bool, LogEvents, true, \ "Enable the various ring buffer event logs") \ \ - diagnostic(uintx, LogEventsBufferEntries, 10, \ + diagnostic(uintx, LogEventsBufferEntries, 20, \ "Number of ring buffer event logs") \ range(1, NOT_LP64(1*K) LP64_ONLY(1*M)) \ \ diff --git a/src/hotspot/share/utilities/events.hpp b/src/hotspot/share/utilities/events.hpp --- a/src/hotspot/share/utilities/events.hpp +++ b/src/hotspot/share/utilities/events.hpp @@ -210,7 +210,7 @@ }; inline void Events::log(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _messages != NULL) { va_list ap; va_start(ap, format); _messages->logv(thread, format, ap); @@ -219,7 +219,7 @@ } inline void Events::log_exception(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _exceptions != NULL) { va_list ap; va_start(ap, format); _exceptions->logv(thread, format, ap); @@ -228,7 +228,7 @@ } inline void Events::log_redefinition(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _redefinitions != NULL) { va_list ap; va_start(ap, format); _redefinitions->logv(thread, format, ap); @@ -237,7 +237,7 @@ } inline void Events::log_deopt_message(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _deopt_messages != NULL) { va_list ap; va_start(ap, format); _deopt_messages->logv(thread, format, ap);