RFR: 8354668: Missing REX2 prefix accounting in ZGC barriers leads to incorrect encoding [v3]

Jatin Bhateja jbhateja at openjdk.org
Thu Apr 17 03:21:08 UTC 2025


> ZGC bookkeeps multiple place holders in barrier code snippets through relocations, these are later used to patch appropriate contents (mostly immediate values) in instruction encoding. While most of the relocation records the patching offsets from the end of the instruction, SHL instruction, which is used for pointer coloring, computes the patching offset from the starting address of the instruction.
> 
> Thus, in case the destination register operand of SHL instruction is an extended GPR register, we miss accounting additional REX2 prefix byte in patch offset, thereby corrupting the encoding since runtime patches the primary opcode byte resulting into ILLEGAL instruction exception.
> 
> This patch fixes reported failures by computing the relocation offset of SHL instruction from end of instruction, thereby making the patch offset agnostic to REX/REX2 prefix.
> 
> Please review and share your feedback.
> 
> Best Regards,
> Jatin
> 
> PS: Validation were performed using latest Intel Software Development Emulator after modifying static register allocation order in x86_64.ad file giving preference to EGPRs.

Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:

  Review comments resolutions

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/24664/files
  - new: https://git.openjdk.org/jdk/pull/24664/files/ffd92c37..dc2b2b16

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24664&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24664&range=01-02

  Stats: 10 lines in 4 files changed: 0 ins; 0 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/24664.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24664/head:pull/24664

PR: https://git.openjdk.org/jdk/pull/24664


More information about the hotspot-gc-dev mailing list