On Mon, 13 Jul 2026 04:28:24 GMT, Ashay Rane <[email protected]> wrote:

>> This patch adds MSVC's "/guard:signret" flag to the C/C++ compilation
>> flags so that the VM code includes signing and authentication
>> instructions to ensure that the return address is not tampered by any
>> callee.  Specifically, MSVC chooses signing using the B key, so every
>> non-leaf function starts with the `pacibsp` instruction (for signining
>> the return address) and ends with the `autibsp` instruction (for
>> authenticating the return address).  Both `pacibsp` and `autibsp`
>> instructions are in the NOP space, so older AArch64 processors that do
>> not support these instructions shouldn't be impacted by these
>> instructions.
>> 
>> As a matter of slight detail, this patch adds the "/guard:signret" flag
>> only when the OpenJDK build is passed the "--enable-branch-protection"
>> flag, which is off by default.  Consequently, this change will not
>> impact ordinary builds of OpenJDK.
>> 
>> I've validated this patch by running the test/jdk:tier{1,2,3},
>> test/hotspot/jtreg:tier{1,2,3}, test/langtools:tier{1,2,3}, and
>> test/lib-test:tier1 tests with branch protection enabled.  This patch
>> does not introduce any new failures.
>> 
>> ---------
>> - [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 incrementally with one additional 
> commit since the last revision:
> 
>   Clarify that Branch Protection is not fully supported

Hi @raneashay 

See my patch here https://github.com/openjdk/jdk/pull/31877

Regarding the latest commit in this PR: should we only mention that branch 
protection is **partially supported** for Windows/ARM64? I suppose it's fully 
supported for **Linux/AArch64** side(when my patch is merged)

Build system change is good to me. I tested this PR on Linux/AArch64 and it 
works as expected.

> Are there any changes in this PR that you think I should remove? 

I didn't find any. I suppose they are necessary in order to support branch 
protection on VM runtime part.

Besides, will you plan to support Java code side on Windows/ARM64?

src/hotspot/os_cpu/windows_aarch64/pauth_windows_aarch64.inline.hpp line 34:

> 32: 
> 33: inline address pauth_strip_pointer(address ptr) {
> 34:   return pauth_drop_signature_win_arm64(ptr);

In the implementation in 
`src/hotspot/cpu/aarch64/continuationFreezeThaw_aarch64.inline.hpp`, we also 
try to strip the signature from the first parameter using instruction 
`XPACLRI`. I was wondering if we could use the similar and simple way as 
Linux/AArch64 side does?

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

PR Review: https://git.openjdk.org/jdk/pull/31795#pullrequestreview-4682126383
PR Review Comment: https://git.openjdk.org/jdk/pull/31795#discussion_r3568375543

Reply via email to