Date: Thu, 23 Feb 2006 10:57:45 +0100 (CET) From: "Arne H. Juul" <arnej@pvv.ntnu.no> To: Ashley Moran <work@ashleymoran.me.uk> Cc: freebsd-java@freebsd.org Subject: Re: i386 java binaries causing 100% cpu on amd64 Message-ID: <Pine.LNX.4.62.0602231052410.23307@decibel.pvv.ntnu.no> In-Reply-To: <200602221524.35585.work@ashleymoran.me.uk> References: <200602221524.35585.work@ashleymoran.me.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 22 Feb 2006, Ashley Moran wrote: > I have an Althlon 64 server running 6.0-rel in amd64 mode. I'm trying to > compile JDK 1.5 on it, and I've gone about it two ways: > > * installing the binary package of the native JDK 1.4 created on my i386 > desktop > * installing emulators/linux_base and the Linux JDK 1.4 > > In both cases, when I run java -version, it does nothing but takes up 100% > CPU. I've stress-tested the system by running an i386 version of the > misc/chef port, and that runs, so the issue is not with i386 binaries in > general. this sounds like the problem I saw where the jdk tries to execute code from the data segment, and the amd64 CPU actually honors the execute protection (i386 traditionally has no notion of execute protection). I think you can use an i386 version of jdk 1.5 to bootstrap, or recompile your i386 jdk 1.4 with the patches below. > Date: Thu, 16 Feb 2006 22:39:30 +0100 > From: Arne Juul <Arne.Juul@europe.yahoo-inc.com> > To: freebsd-java@freebsd.org > Subject: executing data needs mprotect with PROT_EXEC > > I've been trying to run some FreeBSD4 packages > inside a jail on a FreeBSD6 / amd64 box; and I've > hit a problem with ports/jdk. > > A couple of places the VM uses an array of > integers, puts code in it, and executes it. > > This doesn't work on machines where the CPU > honors the PROT_EXEC settings; this can be > different on different machines (depending on > BIOS settings probably). > > The right fix is to call mprotect() from jdk to allow > execution of the memory in question, something like this: --- ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Tue Feb 14 21:12:46 2006 +++ ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Wed Feb 15 16:30:49 2006 @@ -561,6 +562,9 @@ } #else static void (*fixcw)(void) = CAST_TO_FN_PTR(void (*)(void), code_template); + + ::mprotect((void *)code_template, sizeof(code_template), + PROT_EXEC | PROT_READ | PROT_WRITE); #endif fixcw(); --- ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Thu Sep 11 03:40:14 2003 +++ ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Tue Feb 14 23:34:40 2006 @@ -9,6 +9,8 @@ # include "incls/_precompiled.incl" # include "incls/_vm_version_i486.cpp.incl" +#include <sys/types.h> +#include <sys/mman.h> int VM_Version::_cpu; int VM_Version::_cpuFeatures; @@ -145,6 +147,10 @@ ResourceMark rm; // Making this stub must be FIRST use of assembler CodeBuffer* c = new CodeBuffer(address(stubCode), sizeof(stubCode)); + + ::mprotect((void *)stubCode, sizeof(stubCode), + PROT_EXEC | PROT_READ | PROT_WRITE); + VM_Version_StubGenerator g(c); getPsrInfo_stub = CAST_TO_FN_PTR(_getPsrInfo_stub_t, g.generate_getPsrInfo());
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.62.0602231052410.23307>