On Sun, 15 Nov 2026 23:37:58 GMT, Ashay Rane <[email protected]> wrote:

>> This patch enables PAC and AUT instructions for pointer signing and
>> authentication in JIT code on Windows/ARM64 when "UseBranchProtection"
>> flag is set and when the processor supports the feature.
>> 
>> Specifically, JVM detects hardware support by reading ID_AA64ISAR1_EL1
>> and ID_AA64ISAR2_EL1 registers via CP4031 and CP4032 keys in the Windows
>> registry.  Then, if the "UseBranchProtection" flag is set, then HotSpot
>> emits the signing and authenticating instructions.  Windows uses
>> AArch64's "B" key, so this patch selects between "paciaz" and "pacibz"
>> instructions (and similarly, between "autiaz" and "autibz" instructions)
>> depending on whether HotSpot is being compiled for Linux versus Windows.
>> Both the MacroAssembler and the Windows' PAC helpers need to stay in
>> sync, so this patch needs changes to both macroAssembler_aarch64.cpp as
>> well as pauth_windows_aarch64.inline.hpp.
>> 
>> Since Linux supports both "A" as well as "B" keys, it's possible to use
>> "B" keys for both Linux and Windows, although I fear doing so may
>> introduce more churn in the code.
>> 
>> This patch also introduces a cross-platform (Linux and Windows) test
>> that compiles and runs a method under both C1 and C2 before checking
>> whether the generated instructions include the "paci[ab]z" and the
>> "auti[ab]z" instructions.
>> 
>> CI currently doesn't test with branch protection enabled, so I manually
>> changed the default value of "UseBranchProtection" in
>> globals_aarch64.cpp to be "pac-ret" before running tier 1 through tier 3
>> tests in the HotSpot, JDK, and LangTools test groups to ensure that this
>> patch does not introduce any new failures.  I also validated this patch
>> by running the same tests with the default value for
>> "UseBranchProtection".
>> 
>> Going forward, to catch return address corruption bugs, this patch
>> enables branch protection in CI for Windows/ARM64.  We deliberately do
>> not enable branch protection in CI for Linux/AArch64 so that if/when a
>> failure occurs on Windows/ARM64 and if the failure seems unrelated to
>> differences in the OS, then we have a better chance of knowing whether
>> stricter return address protection caused the failure.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Ashay Rane has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains eight additional commits since 
> the last revision:
> 
>  - Merge branch 'master' into JDK-8395991-windows-arm64-jit-pac-ret
>  - Enable branch protection in CI on just Windows/ARM64
>    
>    We deliberately do not enable it on Linux/AArch64 so that depending on
>    whether a failure happens on both Windows/ARM64 and Linux/AArch64 (and
>    assuming that the failure is unrelated to the OS), we have a better
>    chance of knowing whether the failure is related to branch protection.
>  - Merge branch 'master' into JDK-8395991-windows-arm64-jit-pac-ret
>  - Merge branch 'master' into JDK-8395991-windows-arm64-jit-pac-ret
>  - Enable branch protection checks in CI build
>    
>    The intent behind this change is to make CI catch subtle bugs that
>    corrupt return addresses.  Whether the protection is actually enforced
>    depends on whether the GitHub runner uses an AArch64 processor that
>    supports pointer authentication.
>  - Merge branch 'master' into JDK-8395991-windows-arm64-jit-pac-ret
>  - Documentation updates
>    
>    - Include section numbers from ARM ISA document
>    - Mark branch protection on Windows/ARM64 as supported
>  - Enable pointer authentication for JIT code on Windows/ARM64
>    
>    This patch enables PAC and AUT instructions for pointer signing and
>    authentication in JIT code on Windows/ARM64 when "UseBranchProtection"
>    flag is set and when the processor supports the feature.
>    
>    Specifically, JVM detects hardware support by reading ID_AA64ISAR1_EL1
>    and ID_AA64ISAR2_EL1 registers via CP4031 and CP4032 keys in the Windows
>    registry.  Then, if the "UseBranchProtection" flag is set, then HotSpot
>    emits the signing and authenticating instructions.  Windows uses
>    AArch64's "B" key, so this patch selects between "paciaz" and "pacibz"
>    instructions (and similarly, between "autiaz" and "autibz" instructions)
>    depending on whether HotSpot is being compiled for Linux versus Windows.
>    Both the MacroAssembler and the Windows' PAC helpers need to stay in
>    sync, so this patch needs changes to both macroAssembler_aarch64.cpp as
>    well as pauth_windows_aarch64.inline.hpp.
>    
>    Since Linux supports both "A" as well as "B" keys, it's possible to use
>    "B" keys for both Linux and Windows, although I fear doing so may
>    introduce more churn in the code.
>    
>    Th...

Hello Ashay, I haven't been following this change, but just on this part:

> My guess so far is that some GHA runners support "paca" in hardware whereas 
> others don't. So when test/jdk/java/lang/IO/IO.java checks stderr on a 
> machine that doesn't support "paca", the VM prints the warning 
> "ROP-protection specified, but not supported on this CPU. Disabling 
> ROP-protection.", but because the test expects an empty stderr, the test 
> fails.

I think it would be very odd to see such a warning message from the JVM, 
especially for trivial Java applications (like the one in java/lang/IO/IO.java 
test). Plus, it's not actionable either. Would it be possible to have it be 
logged only when `-Xlog` is used (or whatever the existing HotSpot 
recommendation is for such logging)?

Having said that, do you know what's special about the (trivial) program 
launched by the `test/jdk/java/lang/IO/IO.java` test, that it only shows up as 
a failure in this test? As far as I can see, all it does is launch the 
following program with `-Xlog:aot=off -Xlog:cds=off`

import static java.lang.IO.*;
void main() {
    print("1 ");
    print("2 ");
    print("3 ");
    println();
}


I would be surprised if this is the only test in the JDK which fails due to 
unexpected/new warning message being printed by this change. Perhaps those 
additional tests are in higher tiers? Would you be able to run this change 
against tier1, tier2, tier3 and see if there are additional tests that may run 
into issues. It's likely that we will need to run this change against higher 
tiers past tier3, but that can be done once the PR is ready and approved for 
integration.

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

PR Comment: https://git.openjdk.org/jdk/pull/33595#issuecomment-6910284290

Reply via email to