Skip to content

Commit a46b5ac

Browse files
author
Hao Sun
committed
8308503: AArch64: SIGILL when running with -XX:UseBranchProtection=pac-ret on hardware without PAC feature
Reviewed-by: aph, ngasson, dlong
1 parent f9ad7df commit a46b5ac

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/hotspot/cpu/aarch64/vm_version_aarch64.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -452,29 +452,25 @@ void VM_Version::initialize() {
452452

453453
if (UseBranchProtection == nullptr || strcmp(UseBranchProtection, "none") == 0) {
454454
_rop_protection = false;
455-
} else if (strcmp(UseBranchProtection, "standard") == 0) {
455+
} else if (strcmp(UseBranchProtection, "standard") == 0 ||
456+
strcmp(UseBranchProtection, "pac-ret") == 0) {
456457
_rop_protection = false;
457-
// Enable PAC if this code has been built with branch-protection, the CPU/OS
458-
// supports it, and incompatible preview features aren't enabled.
459-
#ifdef __ARM_FEATURE_PAC_DEFAULT
460-
if (VM_Version::supports_paca() && !Arguments::enable_preview()) {
461-
_rop_protection = true;
462-
}
463-
#endif
464-
} else if (strcmp(UseBranchProtection, "pac-ret") == 0) {
465-
_rop_protection = true;
458+
// Enable ROP-protection if
459+
// 1) this code has been built with branch-protection,
460+
// 2) the CPU/OS supports it, and
461+
// 3) incompatible VMContinuations isn't enabled.
466462
#ifdef __ARM_FEATURE_PAC_DEFAULT
467463
if (!VM_Version::supports_paca()) {
468-
warning("ROP-protection specified, but not supported on this CPU.");
469464
// Disable PAC to prevent illegal instruction crashes.
470-
_rop_protection = false;
471-
} else if (Arguments::enable_preview()) {
465+
warning("ROP-protection specified, but not supported on this CPU. Disabling ROP-protection.");
466+
} else if (VMContinuations) {
472467
// Not currently compatible with continuation freeze/thaw.
473-
warning("PAC-RET is incompatible with virtual threads preview feature.");
474-
_rop_protection = false;
468+
warning("ROP-protection is incompatible with VMContinuations. Disabling ROP-protection.");
469+
} else {
470+
_rop_protection = true;
475471
}
476472
#else
477-
warning("ROP-protection specified, but this VM was built without ROP-protection support.");
473+
warning("ROP-protection specified, but this VM was built without ROP-protection support. Disabling ROP-protection.");
478474
#endif
479475
} else {
480476
vm_exit_during_initialization(err_msg("Unsupported UseBranchProtection: %s", UseBranchProtection));

0 commit comments

Comments
 (0)