mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
x86-64: Allocate state buffer space for RDI, RSI and RBX
_dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning stack. After realigning stack, it saves RCX, RDX, R8, R9, R10 and R11. Define TLSDESC_CALL_REGISTER_SAVE_AREA to allocate space for RDI, RSI and RBX to avoid clobbering saved RDI, RSI and RBX values on stack by xsave to STATE_SAVE_OFFSET(%rsp). +==================+<- stack frame start aligned at 8 or 16 bytes | |<- RDI saved in the red zone | |<- RSI saved in the red zone | |<- RBX saved in the red zone | |<- paddings for stack realignment of 64 bytes |------------------|<- xsave buffer end aligned at 64 bytes | |<- | |<- | |<- |------------------|<- xsave buffer start at STATE_SAVE_OFFSET(%rsp) | |<- 8-byte padding for 64-byte alignment | |<- 8-byte padding for 64-byte alignment | |<- R11 | |<- R10 | |<- R9 | |<- R8 | |<- RDX | |<- RCX +==================+<- RSP aligned at 64 bytes Define TLSDESC_CALL_REGISTER_SAVE_AREA, the total register save area size for all integer registers by adding 24 to STATE_SAVE_OFFSET since RDI, RSI and RBX are saved onto stack without adjusting stack pointer first, using the red-zone. This fixes BZ #31501. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
This commit is contained in:
@ -311,7 +311,7 @@ update_active (struct cpu_features *cpu_features)
|
||||
/* NB: On AMX capable processors, ebx always includes AMX
|
||||
states. */
|
||||
unsigned int xsave_state_full_size
|
||||
= ALIGN_UP (ebx + STATE_SAVE_OFFSET, 64);
|
||||
= ALIGN_UP (ebx + TLSDESC_CALL_REGISTER_SAVE_AREA, 64);
|
||||
|
||||
cpu_features->xsave_state_size
|
||||
= xsave_state_full_size;
|
||||
@ -401,8 +401,10 @@ update_active (struct cpu_features *cpu_features)
|
||||
unsigned int amx_size
|
||||
= (xstate_amx_comp_offsets[31]
|
||||
+ xstate_amx_comp_sizes[31]);
|
||||
amx_size = ALIGN_UP (amx_size + STATE_SAVE_OFFSET,
|
||||
64);
|
||||
amx_size
|
||||
= ALIGN_UP ((amx_size
|
||||
+ TLSDESC_CALL_REGISTER_SAVE_AREA),
|
||||
64);
|
||||
/* Set xsave_state_full_size to the compact AMX
|
||||
state size for XSAVEC. NB: xsave_state_full_size
|
||||
is only used in _dl_tlsdesc_dynamic_xsave and
|
||||
@ -410,7 +412,8 @@ update_active (struct cpu_features *cpu_features)
|
||||
cpu_features->xsave_state_full_size = amx_size;
|
||||
#endif
|
||||
cpu_features->xsave_state_size
|
||||
= ALIGN_UP (size + STATE_SAVE_OFFSET, 64);
|
||||
= ALIGN_UP (size + TLSDESC_CALL_REGISTER_SAVE_AREA,
|
||||
64);
|
||||
CPU_FEATURE_SET (cpu_features, XSAVEC);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user