Mercurial > hg > openjdk > jdk6 > hotspot
changeset 4087:ed6d11f66a5d
OPENJDK6-49: Fix placement of 8023956 fix.
Reviewed-by: omajid
author | andrew |
---|---|
date | Tue, 20 Jan 2015 08:03:34 +0000 |
parents | 0dd28ac12d7d |
children | 4f9ce52163cc |
files | src/os_cpu/linux_x86/vm/os_linux_x86.cpp |
diffstat | 1 files changed, 43 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Mon Jan 19 07:36:09 2015 +0000 +++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Tue Jan 20 08:03:34 2015 +0000 @@ -644,49 +644,6 @@ #else return false; #endif - - -/* - * IA32 only: execute code at a high address in case buggy NX emulation is present. I.e. avoid CS limit - * updates (JDK-8023956). - */ -void os::workaround_expand_exec_shield_cs_limit() { -#if defined(IA32) - size_t page_size = os::vm_page_size(); - /* - * Take the highest VA the OS will give us and exec - * - * Although using -(pagesz) as mmap hint works on newer kernel as you would - * think, older variants affected by this work-around don't (search forward only). - * - * On the affected distributions, we understand the memory layout to be: - * - * TASK_LIMIT= 3G, main stack base close to TASK_LIMT. - * - * A few pages south main stack will do it. - * - * If we are embedded in an app other than launcher (initial != main stack), - * we don't have much control or understanding of the address space, just let it slide. - */ - char* hint = (char*) (Linux::initial_thread_stack_bottom() - - ((StackYellowPages + StackRedPages + 1) * page_size)); - char* codebuf = os::pd_attempt_reserve_memory_at(page_size, hint); - if ( (codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true)) ) { - return; // No matter, we tried, best effort. - } - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("[CS limit NX emulation work-around, exec code at: %p]", codebuf); - } - - // Some code to exec: the 'ret' instruction - codebuf[0] = 0xC3; - - // Call the code in the codebuf - __asm__ volatile("call *%0" : : "r"(codebuf)); - - // keep the page mapped so CS limit isn't reduced. -#endif -} } } #endif // AMD64 @@ -905,3 +862,46 @@ : "r" (fpu_cntrl) : "memory"); #endif // !AMD64 } + + +/* + * IA32 only: execute code at a high address in case buggy NX emulation is present. I.e. avoid CS limit + * updates (JDK-8023956). + */ +void os::workaround_expand_exec_shield_cs_limit() { +#if defined(IA32) + size_t page_size = os::vm_page_size(); + /* + * Take the highest VA the OS will give us and exec + * + * Although using -(pagesz) as mmap hint works on newer kernel as you would + * think, older variants affected by this work-around don't (search forward only). + * + * On the affected distributions, we understand the memory layout to be: + * + * TASK_LIMIT= 3G, main stack base close to TASK_LIMT. + * + * A few pages south main stack will do it. + * + * If we are embedded in an app other than launcher (initial != main stack), + * we don't have much control or understanding of the address space, just let it slide. + */ + char* hint = (char*) (Linux::initial_thread_stack_bottom() - + ((StackYellowPages + StackRedPages + 1) * page_size)); + char* codebuf = os::pd_attempt_reserve_memory_at(page_size, hint); + if ( (codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true)) ) { + return; // No matter, we tried, best effort. + } + if (PrintMiscellaneous && (Verbose || WizardMode)) { + tty->print_cr("[CS limit NX emulation work-around, exec code at: %p]", codebuf); + } + + // Some code to exec: the 'ret' instruction + codebuf[0] = 0xC3; + + // Call the code in the codebuf + __asm__ volatile("call *%0" : : "r"(codebuf)); + + // keep the page mapped so CS limit isn't reduced. +#endif +}