https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79793
--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> --- (In reply to H.J. Lu from comment #5) > In 64-bit mode, stack is 16-byte aligned when entering handler. But if > there is error code > > SS > RSP > FLAGS > CS > RIP > Error Code > > the stack alignment is off by 8 bytes. That is %rsp + 8 isn't multiple > of 16 at the start of handler. A testcase: [hjl@gnu-skl-1 pr79793]$ cat y.c #include <fxsrintrin.h> typedef unsigned int uword_t __attribute__ ((mode (__word__))); struct interrupt_frame { uword_t ip; uword_t cs; uword_t flags; uword_t sp; uword_t ss; }; __attribute__((interrupt)) void fn (struct interrupt_frame *frame, uword_t error) { char fxsave_region [512] __attribute__((aligned(16))); _fxsave64 (fxsave_region); } [hjl@gnu-skl-1 pr79793]$ make y.s /export/build/gnu/gcc-x32-7/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-x32-7/build-x86_64-linux/gcc/ -O2 -mgeneral-regs-only -S -o y.s y.c [hjl@gnu-skl-1 pr79793]$ cat y.s .file "y.c" .text .p2align 4,,15 .globl fn .type fn, @function fn: .LFB4: .cfi_startproc subq $400, %rsp .cfi_def_cfa_offset 408 fxsave64 -120(%rsp) addq $408, %rsp iretq .cfi_endproc .LFE4: .size fn, .-fn .ident "GCC: (GNU) 7.1.1 20170724" .section .note.GNU-stack,"",@progbits [hjl@gnu-skl-1 pr79793]$ -120(%rsp) isn't aligned at 16 bytes. For [hjl@gnu-skl-1 pr79793]$ cat x.c #include <fxsrintrin.h> typedef unsigned int uword_t __attribute__ ((mode (__word__))); struct interrupt_frame { uword_t ip; uword_t cs; uword_t flags; uword_t sp; uword_t ss; }; __attribute__((interrupt)) void fn (struct interrupt_frame *frame) { char fxsave_region [512] __attribute__((aligned(16))); _fxsave64 (fxsave_region); } [hjl@gnu-skl-1 pr79793]$ make x.s /export/build/gnu/gcc-x32-7/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-x32-7/build-x86_64-linux/gcc/ -O2 -mgeneral-regs-only -S -o x.s x.c [hjl@gnu-skl-1 pr79793]$ cat x.s .file "x.c" .text .p2align 4,,15 .globl fn .type fn, @function fn: .LFB4: .cfi_startproc subq $400, %rsp .cfi_def_cfa_offset 408 fxsave64 -120(%rsp) addq $400, %rsp .cfi_def_cfa_offset 8 iretq .cfi_endproc .LFE4: .size fn, .-fn .ident "GCC: (GNU) 7.1.1 20170724" .section .note.GNU-stack,"",@progbits [hjl@gnu-skl-1 pr79793]$ -120(%rsp) is aligned at 16 bytes.