Skip to content

Commit

Permalink
8308503: AArch64: SIGILL when running with -XX:UseBranchProtection=pa…
Browse files Browse the repository at this point in the history
…c-ret on hardware without PAC feature

Reviewed-by: aph, ngasson, dlong
  • Loading branch information
Hao Sun committed May 31, 2023
1 parent f9ad7df commit a46b5ac
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,29 +452,25 @@ void VM_Version::initialize() {

if (UseBranchProtection == nullptr || strcmp(UseBranchProtection, "none") == 0) {
_rop_protection = false;
} else if (strcmp(UseBranchProtection, "standard") == 0) {
} else if (strcmp(UseBranchProtection, "standard") == 0 ||
strcmp(UseBranchProtection, "pac-ret") == 0) {
_rop_protection = false;
// Enable PAC if this code has been built with branch-protection, the CPU/OS
// supports it, and incompatible preview features aren't enabled.
#ifdef __ARM_FEATURE_PAC_DEFAULT
if (VM_Version::supports_paca() && !Arguments::enable_preview()) {
_rop_protection = true;
}
#endif
} else if (strcmp(UseBranchProtection, "pac-ret") == 0) {
_rop_protection = true;
// Enable ROP-protection if
// 1) this code has been built with branch-protection,
// 2) the CPU/OS supports it, and
// 3) incompatible VMContinuations isn't enabled.
#ifdef __ARM_FEATURE_PAC_DEFAULT
if (!VM_Version::supports_paca()) {
warning("ROP-protection specified, but not supported on this CPU.");
// Disable PAC to prevent illegal instruction crashes.
_rop_protection = false;
} else if (Arguments::enable_preview()) {
warning("ROP-protection specified, but not supported on this CPU. Disabling ROP-protection.");
} else if (VMContinuations) {
// Not currently compatible with continuation freeze/thaw.
warning("PAC-RET is incompatible with virtual threads preview feature.");
_rop_protection = false;
warning("ROP-protection is incompatible with VMContinuations. Disabling ROP-protection.");
} else {
_rop_protection = true;
}
#else
warning("ROP-protection specified, but this VM was built without ROP-protection support.");
warning("ROP-protection specified, but this VM was built without ROP-protection support. Disabling ROP-protection.");
#endif
} else {
vm_exit_during_initialization(err_msg("Unsupported UseBranchProtection: %s", UseBranchProtection));
Expand Down

3 comments on commit a46b5ac

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperIRL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tag jdk-21+25

@openjdk
Copy link

@openjdk openjdk bot commented on a46b5ac Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperIRL The tag jdk-21+25 was successfully created.

Please sign in to comment.