8308503: AArch64: SIGILL when running with -XX:UseBranchProtection=pac-ret on hardware without PAC feature

Reviewed-by: aph, ngasson, dlong
This commit is contained in:
Hao Sun 2023-05-31 23:49:13 +00:00
parent f9ad7df4da
commit a46b5acc15

@ -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));