From a46b5acc15359cabbfe19eec32f468df544b044c Mon Sep 17 00:00:00 2001 From: Hao Sun Date: Wed, 31 May 2023 23:49:13 +0000 Subject: [PATCH] 8308503: AArch64: SIGILL when running with -XX:UseBranchProtection=pac-ret on hardware without PAC feature Reviewed-by: aph, ngasson, dlong --- .../cpu/aarch64/vm_version_aarch64.cpp | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index 994e32c7ad0..26aaf75ab81 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -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));