RFR: 8262894: [macos_aarch64] SIGBUS in Assembler::ld_st2

Anton Kozlov akozlov at openjdk.java.net
Tue Mar 30 07:14:40 UTC 2021


On Mon, 29 Mar 2021 19:15:20 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:

>> Hi Anton,
>> 
>> In so much as I understand the fact transitions are missing the introduction of those transitions seems fine - but can be simplified due to an existing code quirk (see comments below).
>> 
>> My main concern with this W^X stuff is that I don't see a clear way to know exactly where a transition needs to be placed. The missing cases here suggest it should be handled in the thread-state transition code, but you've previously written:
>> 
>> " when we execute JVM code (owned by libjvm.so, starting from JVM entry function), we switch to Write state. When we leave JVM to execute generated or JNI code, we switch to Executable state. I would like to highlight that JVM code does not mean the VM state of the java thread"
>> 
>> so I'm unclear exactly how we identify the points where these transitions must occur? What kind of "VM code" must be guarded this way? I don't see this documented in the code anywhere.
>> 
>> Thanks,
>> David
>
> Hi David,
> 
> Thank you for the review. 
> 
>> so I'm unclear exactly how we identify the points where these transitions must occur? What kind of "VM code" must be guarded this way? I don't see this documented in the code anywhere.
> 
> For usual JNI function implementation we switch to WXWrite in JNI_ENTRY (JNI_ENTRY_NO_PRESERVE to be precise), so xxx_ENTRY style macro defines a border between JVM and the rest of the code. JNI Invocation functions are also called directly from native code, so they should have W^X transition. But since they are implementing something rather special, they don't use any special ENTRY macro, which makes them less evident to be JVM entry points. Here and in other cases, when we do W^X in an apparently random function, it is because the function is called directly from the interpreter or native or generated code, but the function is not defined with ENTRY macro. Hope it clarifies the logic a bit.
> 
> I've checked `Threads::destroy_vm`, you're right! But I'd consider missing handling after possible `false` as a bug. If you don't mind, I prefer the extra code in the existing else clause. But I agree the whole clause can be cleaned up. Thanks for pointing!

> what kind of
> VM code actually requires these transitions. For example a LEAF function
> doesn't have the transition so the code called from there can't require
> it - but what is the characteristic of code that can require it?

I assume any VM entry code should have W^X transitions. Now VM_LEAF_BASE transits to WXWrite, and the macro is used in various kinds of LEAF's. An initial W^X implementation had no transitions in LEAF functions, but now the code and W^X policy should be much more straightforward. If we still don't have the transition somewhere, there should be a reason and a comment in the code. Otherwise, it's a bug :)

-------------

PR: https://git.openjdk.java.net/jdk/pull/3241


More information about the hotspot-dev mailing list