Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
b14c031
8385359: [CRaC] aarch64: c7g.medium <-> c8g.medium FAIL: vector length
jankratochvil Jul 23, 2026
8c52894
rename: boolvalue -> image_supports_sve256
jankratochvil Jul 23, 2026
d985dad
Fix Gitlab CI
jankratochvil Jul 23, 2026
e08bde7
Fix whitespace
jankratochvil Jul 23, 2026
fa57bb5
Fix one forgotten maximum_sve_vector_length set
jankratochvil Jul 23, 2026
a46f297
Fix aarch64 build
jankratochvil Jul 23, 2026
b46ded6
Remove dead code
jankratochvil Jul 23, 2026
d5f84fa
Fix CheckCPUFeaturesTest.java
jankratochvil Jul 23, 2026
15449dd
Fix linux-cross-compile
jankratochvil Jul 23, 2026
0f62afa
Fix SIGSEGV
jankratochvil Jul 23, 2026
b86c5ff
Follow -XX::CheckCPUFeatures=skip
jankratochvil Jul 23, 2026
768aae4
restore_pre -> pre_restore
jankratochvil Jul 24, 2026
588ee21
Provide should_skip_cpu_features_check()
jankratochvil Jul 24, 2026
52d526c
+get_label, +get_bitmap
jankratochvil Jul 24, 2026
cb71018
Fix get_label,get_bitmap
jankratochvil Jul 24, 2026
8db9bc7
Compilation fix
jankratochvil Jul 24, 2026
cbb0746
Compilation fix #2
jankratochvil Jul 24, 2026
be48727
Fix a race in CPUFeaturesAWS.sh
jankratochvil Jul 24, 2026
09f983f
An unrelated fix for get_failed_bitmap
jankratochvil Jul 24, 2026
5e060d9
%m fix
jankratochvil Jul 24, 2026
5ea5d93
Fix secondary arches compilation
jankratochvil Jul 24, 2026
9e5927d
Fix ups
jankratochvil Jul 24, 2026
205080e
Fix compilation
jankratochvil Jul 25, 2026
c3d3644
get_* -> register_*_hook
jankratochvil Jul 26, 2026
7c8c827
fixups
jankratochvil Jul 26, 2026
000138b
Compilation fix
jankratochvil Jul 26, 2026
7eb8b88
Fix the 1st x86_64 testcase regresion
jankratochvil Jul 26, 2026
fc737cc
Fix aarch64 compilation
jankratochvil Jul 27, 2026
4c4a201
check_cpu_features_skip()->get_cpu_features_ignore()
jankratochvil Jul 28, 2026
0340e76
Message fix Invalid -> Incompatible
jankratochvil Jul 28, 2026
32cf9c8
Use prepare_image_constraints_api()
jankratochvil Jul 28, 2026
416e168
rename:
jankratochvil Jul 28, 2026
c1253a6
Remove pre_restore_bitmap_hook_trampoline
jankratochvil Jul 29, 2026
297ce42
Rename get_cpu_features_ignore() -> cpu_features_ignore()
jankratochvil Jul 29, 2026
d417007
Inline should_skip_cpu_features_check()
jankratochvil Jul 29, 2026
8b6f0af
Fix aarch64 compilation
jankratochvil Jul 29, 2026
6473fb2
cpu_features_ignore() -> !can_use_cpu_features()
jankratochvil Jul 29, 2026
667defa
Fix vec128/256 for image selection
jankratochvil Jul 29, 2026
a78f4a3
Fix aarch64 multiple images selection
jankratochvil Jul 29, 2026
28104d1
+restore_cpuinfo()
jankratochvil Jul 30, 2026
77a7638
Cosmetic message unification
jankratochvil Jul 31, 2026
e4a1397
Merge branch 'crac' into 8385359
jankratochvil Sep 8, 2026
4483852
Fix the merge
jankratochvil Sep 8, 2026
56026c8
want -> want_sve_vector_length rename
jankratochvil Sep 8, 2026
30ca564
+VM_Version::checkpoint_check() to verify >256 vector bits CPUs
jankratochvil Sep 13, 2026
cf9925e
Run all _hooks .
jankratochvil Sep 13, 2026
37f8508
Add missing ResourceMark.
jankratochvil Sep 13, 2026
e341257
Add #include "memory/resourceArea.hpp"
jankratochvil Sep 13, 2026
6952eec
Remove excessive ;
jankratochvil Sep 13, 2026
12905e7
CPUFeaturesAWS.sh: call dash, not bash
jankratochvil Sep 13, 2026
6075049
Fix TID sorting
jankratochvil Sep 13, 2026
c030824
Add the new methods to ppc/riscv/s390 .
jankratochvil Sep 13, 2026
79a0d61
Merge branch 'crac' into 8385359
jankratochvil Sep 13, 2026
7603eaf
Fix an SVE assertion
jankratochvil Sep 13, 2026
6835607
Fix an SVE assertion
jankratochvil Sep 13, 2026
e333e78
Another ppc/riscv/s390 compilation fix.
jankratochvil Sep 13, 2026
2d311da
+has_method(_image_constraints_api, register_bitmap_hook)
jankratochvil Sep 13, 2026
7248e09
Fix another assertion
jankratochvil Sep 13, 2026
0f6f2f5
Fix the TID in testcase
jankratochvil Sep 13, 2026
2e84219
ResourceMark is not permitted here
jankratochvil Sep 13, 2026
d484593
Proper !CPU_SVE256 fix
jankratochvil Sep 13, 2026
821f3d9
Whitespace cleanup
jankratochvil Sep 13, 2026
9a36bc1
Use -XX:MaxVectorSize in the launcher only for is_restore
jankratochvil Sep 13, 2026
35a5335
ImageConstraints::validate - do not return early on a failed hook
jankratochvil Sep 13, 2026
a6a3c4d
Call set_maximum_sve_vector_length unconditionally
jankratochvil Sep 13, 2026
f295afc
Use -XX:MaxVectorSize in the launcher only for is_checkpoint
jankratochvil Sep 13, 2026
8053085
Fix non-linux aarch64 assertion
jankratochvil Sep 14, 2026
f84dd4e
Fix windows-aarch64 assertion
jankratochvil Sep 15, 2026
06f2f34
RestoreCpuInfo -> defer
jankratochvil Sep 15, 2026
787a7e8
Rework the API to prepare_restore&co.
jankratochvil Sep 16, 2026
9b58647
Remove leftover *Hook types
jankratochvil Sep 16, 2026
27a6033
Make CracEngine::require_cpuinfo return a real result
jankratochvil Sep 16, 2026
9adf3ab
Call the callback
jankratochvil Sep 16, 2026
c224ffb
Fix bitmap size differences
jankratochvil Sep 16, 2026
2eedf43
Fix the "try using -XX:MaxVectorSize=16 ..." error
jankratochvil Sep 16, 2026
0fc8d9d
Fix extra logging of "Bitmap store for tag"
jankratochvil Sep 17, 2026
277235c
whitespace
jankratochvil Sep 17, 2026
372753c
_callback -> _prepare_restore_callback
jankratochvil Sep 17, 2026
d2e59b1
Fix common size of bitmap comparison
jankratochvil Sep 17, 2026
a17ee6d
Fix incorrect data_size
jankratochvil Sep 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
GLIBC_UNSUPPORTED(A53MAC ); \
GLIBC_UNSUPPORTED(ECV ); \
GLIBC_UNSUPPORTED(WFXT ); \
GLIBC_UNSUPPORTED(SVE256 ); \
GLIBC_UNSUPPORTED(NOTPACA ); \
/**/
#include "runtime/abstract_vm_version.inline.hpp"
Expand Down Expand Up @@ -930,3 +931,32 @@ void VM_Version::CPUFeatures_apply_arch(VM_Features &parsed, VM_Features &missin
missing.clear_feature(CPU_PACA);
missing.clear_feature(CPU_NOTPACA);
}

bool VM_Version::restore_pre(VM_Features image_features, const char *image_location) {
bool boolvalue = image_features.supports_feature(CPU_SVE256);
Comment thread
jankratochvil marked this conversation as resolved.
Outdated
if (boolvalue == _cpu_features.supports_feature(CPU_SVE256)) {
return true;
}
if (boolvalue && !_cpu_features.supports_feature(CPU_SVE256)) {
ResourceMark rm;
stringStream ss;
VM_Features sve256;
sve256.set_feature(CPU_SVE256);
VM_Features use = image_features & _cpu_features;
log_error(crac)("Image %s has -XX:CPUFeatures=%s with CPU_SVE256=%s, this CPU has CPUFeatures=%s not supporting CPU_SVE256, use -XX:CPUFeatures=%s during snapshot",
image_location, image_features.print_numbers(), sve256.print_numbers(), _cpu_features.print_numbers(), use.print_numbers());
return false;
}
errno = 0;
int got = set_and_get_current_sve_vector_length(16);
if (got != 16) {
ResourceMark rm;
stringStream ss;
VM_Features sve256;
sve256.set_feature(CPU_SVE256);
log_error(crac)("Image %s has -XX:CPUFeatures=%s with CPU_SVE256=%s unset, this CPU has CPUFeatures=%s but PR_SVE_SET_VL reports %d: %m",
image_location, image_features.print_numbers(), sve256.print_numbers(), _cpu_features.print_numbers(), got);
return false;
}
return true;
}
5 changes: 4 additions & 1 deletion src/hotspot/cpu/aarch64/vm_version_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class VM_Feature_Flag {
decl(ECV, ecv, 21) \
decl(WFXT, wfxt, 22) \
/* These features are added for CRaC. */ \
decl(SVE256, sve256, 62) \
decl(NOTPACA, notpaca, 63) \
/**/

Expand All @@ -68,7 +69,7 @@ class VM_Feature_Flag {
#undef DECLARE_CPU_FEATURE_FLAG
MAX_CPU_FEATURES,
LAST_CPU_FEATURE = CPU_WFXT,
FIRST_GLIBC_FEATURE = CPU_NOTPACA
FIRST_GLIBC_FEATURE = CPU_SVE256
};
};

Expand Down Expand Up @@ -142,6 +143,8 @@ class VM_Version : public Abstract_VM_Version, public VM_Feature_Flag {
static void insert_features_names(VM_Version::VM_Features features, outputStream& os);
// The returned string needs a ResourceMark.
static const char *restore_failed_check(const VM_Features *image_features, const VM_Features *current_features);
static bool restore_pre(VM_Features image_features, const char *image_location);
static constexpr bool restore_pre_needed = true;

static void print_platform_virtualization_info(outputStream*);

Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/x86/vm_version_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,10 @@ class VM_Version : public Abstract_VM_Version, protected VM_Feature_Flag {
static const char *restore_failed_check(const VM_Features *image_features, const VM_Features *current_features) {
return nullptr;
}
static bool restore_pre(VM_Features image_features, const char *image_location) {
return false;
}
static constexpr bool restore_pre_needed = false;

static bool os_supports_avx_vectors();
static bool os_supports_apx_egprs();
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/zero/vm_version_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class VM_Version : public Abstract_VM_Version {
static const char *restore_failed_check(const VM_Features *image_features, const VM_Features *current_features) {
return nullptr;
}
static bool restore_pre(VM_Features image_features, const char *image_location) {
return false;
}
static constexpr bool restore_pre_needed = false;

constexpr static bool supports_stack_watermark_barrier() { return true; }

Expand Down
30 changes: 29 additions & 1 deletion src/hotspot/os_cpu/linux_aarch64/vm_version_linux_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

#include "memory/resourceArea.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
#include "runtime/os.inline.hpp"
Expand Down Expand Up @@ -120,9 +121,12 @@ int VM_Version::get_current_sve_vector_length() {
return prctl(PR_SVE_GET_VL);
}

// Limit what set_and_get_current_sve_vector_length is willing to set.
static int maximum_sve_vector_length = INT_MAX;

int VM_Version::set_and_get_current_sve_vector_length(int length) {
assert(VM_Version::supports_sve(), "should not call this");
int new_length = prctl(PR_SVE_SET_VL, length);
int new_length = prctl(PR_SVE_SET_VL, MIN2(length, maximum_sve_vector_length));
return new_length;
}

Expand Down Expand Up @@ -163,6 +167,10 @@ void VM_Version::get_os_cpu_info() {
update_feature(auxv2, CPU_WFXT, HWCAP2_WFXT );
update_feature(~auxv, CPU_NOTPACA, HWCAP_PACA );

if (supports_sve() && get_current_sve_vector_length() == 32) {
set_feature(CPU_SVE256);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The rest of the code seems to assume that !supports_feature(CPU_SVE256) => supports SVE128 (or less?), but I read there are CPUs with SVE vector lengths higher than 256 bits. Not sure JDK can run on them though. Is it guaranteed somewhere that higher lengths are not possible in this code?

@TimPushkin TimPushkin Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI also complains about smaller sizes, resending verbatim:

  • "get_os_cpu_info sets the bit only when VL is exactly 32, so a VL=64 machine (A64FX etc.) is indistinguishable from VL=16. On restore, want = image_supports_sve256 ? 32 : 16 then hard-sets VL to 16 — including when checkpointing and restoring on the same VL=64 host, where the restored JVM's code was compiled for MaxVectorSize=64. That's a silent miscompile/SIGILL, not a clean failure."
  • "process_image_cpu_features(nullptr) recomputes 16/32 from _features rather than restoring what get_current_sve_vector_length() was before the hook ran. With -XX:MaxVectorSize=16 on an SVE256 CPU plus a failed restore and -XX:+CRaCIgnoreRestoreIfUnavailable (where the VM keeps running), the process ends up with VL=32 while its compiled code assumed 16."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed by: +VM_Version::checkpoint_check() to verify >256 vector bits CPUs


uint64_t ctr_el0;
uint64_t dczid_el0;
__asm__ (
Expand Down Expand Up @@ -226,6 +234,26 @@ void VM_Version::check_os_cpu_info() {
// GLIBC_TUNABLES=glibc.cpu.hwcaps is unsupported on aarch64
vm_exit_during_initialization(err_msg("LSE (%s) cannot be disabled via -XX:CPUFeatures on aarch64.", lse.print_numbers()));
}
if (FLAG_IS_DEFAULT(CPUFeatures)) {
assert(_cpu_features.supports_feature(CPU_SVE256) == _features.supports_feature(CPU_SVE256), "CPU_SVE256 is not changed");
} else if (!_cpu_features.supports_feature(CPU_SVE256) && _features.supports_feature(CPU_SVE256)) {
stringStream ss;
VM_Features sve256;
sve256.set_feature(VM_Feature_Flag::CPU_SVE256);
ss.print("Specified -XX:CPUFeatures=%s have CPU_SVE256=%s set but this CPU does not support it", _features.print_numbers(), sve256.print_numbers());
Comment thread
jankratochvil marked this conversation as resolved.
Outdated
vm_exit_during_initialization(ss.base());
} else if (_cpu_features.supports_feature(CPU_SVE256) && !_features.supports_feature(CPU_SVE256)) {
maximum_sve_vector_length = 16;
int got = set_and_get_current_sve_vector_length(maximum_sve_vector_length);
if (got != maximum_sve_vector_length) {
stringStream ss;
VM_Features sve256;
sve256.set_feature(VM_Feature_Flag::CPU_SVE256);
ss.print("Specified -XX:CPUFeatures=%s have unset CPU_SVE256=%s, this CPU has CPUFeatures=%s but it cannot be disabled as PR_SVE_SET_VL reports %d: %m",
_features.print_numbers(), sve256.print_numbers(), _cpu_features.print_numbers(), got);
Comment thread
rvansa marked this conversation as resolved.
vm_exit_during_initialization(ss.base());
}
}
}

static bool read_fully(const char *fname, char *buf, size_t buflen) {
Expand Down
85 changes: 85 additions & 0 deletions src/hotspot/share/runtime/crac_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,96 @@
return _api->checkpoint(_conf);
}

static inline unsigned char from_hex(char c, bool* err) {
if (c >= '0' && c <= '9') {
return c - '0';
} else if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
} else {
*err = true;
return 0;
}
}

static constexpr char cpufeatures_prefix[] = "bitmap:cpu.features";

// FIXME: Replace "tags" parsing by a new constraint reader method call.
bool CracEngine::restore_pre_core(FILE *f) const {
static constexpr const size_t _MAX_VALUE_SIZE = 256;
char line[sizeof(cpufeatures_prefix) + 1 + _MAX_VALUE_SIZE + 2];
while (fgets(line, (int) sizeof(line), f)) {
char* eq = strchr((char *) line, '=');
char* nl = strchr((char *) (eq + 1), '\n');
if (eq == nullptr || nl == nullptr) {
log_error(crac)("Invalid format of tags file of image %s: %s", _image_location, line);
return false;
}
*eq = 0;
*nl = 0;
if (eq < nl && !strncmp(line, cpufeatures_prefix, strlen(cpufeatures_prefix)) && eq - line == strlen(cpufeatures_prefix)) {
size_t length = (size_t)(nl - eq - 1)/2;
if (2 * length != (size_t)(nl - eq - 1)) {
log_error(crac)("Invalid format of tags file (bad bitmap) of image %s: %s", _image_location, line);
return false;
}
union {
VM_Version::VM_Features features;

Check failure on line 414 in src/hotspot/share/runtime/crac_engine.cpp

View check run for this annotation

openjdk / jcheck-openjdk/crac-331

Whitespace error

Column 0: tab
uint8_t bytes[sizeof(VM_Version::VM_Features)] = { 0 };

Check failure on line 415 in src/hotspot/share/runtime/crac_engine.cpp

View check run for this annotation

openjdk / jcheck-openjdk/crac-331

Whitespace error

Column 0: tab
} u;
bool err = false;
for (size_t i = 0; i < length; ++i) {
u.bytes[i] = (from_hex(eq[1 + 2 * i], &err) << 4) + from_hex(eq[2 + 2 * i], &err);
}
if (err) {
log_error(crac)("Invalid format of tags file (bad character in bitmap): %s", line);
return false;
}
return VM_Version::restore_pre(u.features, _image_location);
}
}
log_error(crac)("%s not found in image %s", cpufeatures_prefix, _image_location);
return false;
}

static FILE* open_tags(const char* image_location, const char* mode) {
char fname[PATH_MAX];
if (os::snprintf(fname, sizeof(fname), "%s/tags", image_location) >= (int) sizeof(fname) - 1) {
log_error(crac)("filename too long: %s/tags", image_location);
return nullptr;
}
FILE* f = fopen(fname, mode);
if (f == nullptr) {
log_error(crac)("cannot open %s in mode %s: %s", fname, mode, os::strerror(errno));
return nullptr;
}
return f;
}

bool CracEngine::restore_pre() const {
if (!VM_Version::restore_pre_needed) {
return true;
}
FILE* f = open_tags(_image_location, "r");
if (f == nullptr) {
log_error(crac)("Cannot open tags for image %s", _image_location);
return false;
}
bool retval = restore_pre_core(f);
if (fclose(f)) {
log_error(crac)("cannot close %s/tags: %s", _image_location, os::strerror(errno));
return false;
}
Comment thread
TimPushkin marked this conversation as resolved.
Outdated
return retval;
}

int CracEngine::restore() const {
precond(is_initialized());
if (!check_engine(_name, _image_location)) {
return -1;
}
if (!restore_pre()) {
return -1;
}
return _api->restore(_conf);
}

Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/runtime/crac_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class CracEngine : public CHeapObj<mtInternal> {
crlib_image_score_t *_image_score_api = nullptr;

crlib_conf_option_t *_options = nullptr;

bool restore_pre() const;
bool restore_pre_core(FILE *f) const;
};

#endif // SHARE_RUNTIME_CRAC_ENGINE_HPP
9 changes: 5 additions & 4 deletions test/jdk/jdk/crac/CPUFeatures/CPUFeaturesAWS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,12 @@ checkpoint_restore "$LINENO" a1.medium t4g.micro
checkpoint_restore "$LINENO" t4g.micro a1.medium "1:Restore failed due to incompatible or missing CPU features, try using -XX:CPUFeatures=0x80000000000000ff on checkpoint."
checkpoint_restore "$LINENO" t4g.micro a1.medium "-1:LSE (0x100) cannot be disabled via -XX:CPUFeatures on aarch64." "-XX:CPUFeatures=0x80000000000000ff" ""

# JDK-8385359: checkpoint_restore "$LINENO" c7g.medium c7g.medium
# JDK-8385359: checkpoint_restore "$LINENO" c8g.medium c8g.medium
# JDK-8385359: checkpoint_restore "$LINENO" c7g.medium c8g.medium
checkpoint_restore "$LINENO" c7g.medium c7g.medium
checkpoint_restore "$LINENO" c8g.medium c8g.medium
checkpoint_restore "$LINENO" c7g.medium c8g.medium "1:Image cr has -XX:CPUFeatures=0x4000000000017fff with CPU_SVE256=0x4000000000000000, this CPU has CPUFeatures=0x77fff not supporting CPU_SVE256, use -XX:CPUFeatures=0x17fff during snapshot"
checkpoint_restore "$LINENO" c7g.medium c8g.medium "" "-XX:CPUFeatures=0x17fff" ""
checkpoint_restore "$LINENO" c8g.medium c7g.medium "1:Restore failed due to incompatible or missing CPU features, try using -XX:CPUFeatures=0x17fff on checkpoint."
# JDK-8385359: checkpoint_restore "$LINENO" c8g.medium c7g.medium "" "-XX:CPUFeatures=0x17fff" ""
checkpoint_restore "$LINENO" c8g.medium c7g.medium "" "-XX:CPUFeatures=0x17fff" ""

checkpoint_restore "$LINENO" t4g.micro c8g.medium "1:Restore failed due to incompatible aarch64 CPU feature PACA (0x10000); these CPUs each require a separate image."
checkpoint_restore "$LINENO" c8g.medium t4g.micro "1:Restore failed due to incompatible aarch64 CPU feature PACA (0x10000); these CPUs each require a separate image."
Expand Down