Skip to content

Commit 53ad4b2

Browse files
Jatin Bhatejaxmas92
andcommitted
8355364: [REDO] Missing REX2 prefix accounting in ZGC barriers leads to incorrect encoding
Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org> Reviewed-by: aboldtch, sviswanathan
1 parent 9a0e6f3 commit 53ad4b2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,13 @@ void ZBarrierSetAssembler::patch_barrier_relocation(address addr, int format) {
13281328
const uint16_t value = patch_barrier_relocation_value(format);
13291329
uint8_t* const patch_addr = (uint8_t*)addr + offset;
13301330
if (format == ZBarrierRelocationFormatLoadGoodBeforeShl) {
1331-
*patch_addr = (uint8_t)value;
1331+
if (VM_Version::supports_apx_f()) {
1332+
NativeInstruction* instruction = nativeInstruction_at(addr);
1333+
uint8_t* const rex2_patch_addr = patch_addr + (instruction->has_rex2_prefix() ? 1 : 0);
1334+
*rex2_patch_addr = (uint8_t)value;
1335+
} else {
1336+
*patch_addr = (uint8_t)value;
1337+
}
13321338
} else {
13331339
*(uint16_t*)patch_addr = value;
13341340
}

0 commit comments

Comments
 (0)