xref: /openbmc/linux/arch/x86/include/asm/sigframe.h (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
25c2628e8SHiroshi Shimamoto #ifndef _ASM_X86_SIGFRAME_H
35c2628e8SHiroshi Shimamoto #define _ASM_X86_SIGFRAME_H
45c2628e8SHiroshi Shimamoto 
5decb4c41SIngo Molnar #include <uapi/asm/sigcontext.h>
6b2fa739cSHiroshi Shimamoto #include <asm/siginfo.h>
7b2fa739cSHiroshi Shimamoto #include <asm/ucontext.h>
8b829d1beSBrian Gerst #include <linux/compat.h>
9b2fa739cSHiroshi Shimamoto 
1041af86faSHiroshi Shimamoto #ifdef CONFIG_X86_32
1141af86faSHiroshi Shimamoto #define sigframe_ia32		sigframe
1241af86faSHiroshi Shimamoto #define rt_sigframe_ia32	rt_sigframe
1341af86faSHiroshi Shimamoto #define ucontext_ia32		ucontext
14c85c2ff8SHiroshi Shimamoto #else /* !CONFIG_X86_32 */
1541af86faSHiroshi Shimamoto 
16c85c2ff8SHiroshi Shimamoto #ifdef CONFIG_IA32_EMULATION
17c85c2ff8SHiroshi Shimamoto #include <asm/ia32.h>
18c85c2ff8SHiroshi Shimamoto #endif /* CONFIG_IA32_EMULATION */
19c85c2ff8SHiroshi Shimamoto 
20c85c2ff8SHiroshi Shimamoto #endif /* CONFIG_X86_32 */
21c85c2ff8SHiroshi Shimamoto 
22c85c2ff8SHiroshi Shimamoto #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
2341af86faSHiroshi Shimamoto struct sigframe_ia32 {
2441af86faSHiroshi Shimamoto 	u32 pretcode;
2541af86faSHiroshi Shimamoto 	int sig;
268fcb346bSIngo Molnar 	struct sigcontext_32 sc;
2741af86faSHiroshi Shimamoto 	/*
2841af86faSHiroshi Shimamoto 	 * fpstate is unused. fpstate is moved/allocated after
2941af86faSHiroshi Shimamoto 	 * retcode[] below. This movement allows to have the FP state and the
3041af86faSHiroshi Shimamoto 	 * future state extensions (xsave) stay together.
3141af86faSHiroshi Shimamoto 	 * And at the same time retaining the unused fpstate, prevents changing
3241af86faSHiroshi Shimamoto 	 * the offset of extramask[] in the sigframe and thus prevent any
3341af86faSHiroshi Shimamoto 	 * legacy application accessing/modifying it.
3441af86faSHiroshi Shimamoto 	 */
3586e9fc3aSIngo Molnar 	struct _fpstate_32 fpstate_unused;
36*71c3313aSAl Viro 	unsigned int extramask[1];
3741af86faSHiroshi Shimamoto 	char retcode[8];
3841af86faSHiroshi Shimamoto 	/* fp state follows here */
3941af86faSHiroshi Shimamoto };
4041af86faSHiroshi Shimamoto 
4141af86faSHiroshi Shimamoto struct rt_sigframe_ia32 {
4241af86faSHiroshi Shimamoto 	u32 pretcode;
4341af86faSHiroshi Shimamoto 	int sig;
4441af86faSHiroshi Shimamoto 	u32 pinfo;
4541af86faSHiroshi Shimamoto 	u32 puc;
46c85c2ff8SHiroshi Shimamoto #ifdef CONFIG_IA32_EMULATION
47c85c2ff8SHiroshi Shimamoto 	compat_siginfo_t info;
48c85c2ff8SHiroshi Shimamoto #else /* !CONFIG_IA32_EMULATION */
4941af86faSHiroshi Shimamoto 	struct siginfo info;
50c85c2ff8SHiroshi Shimamoto #endif /* CONFIG_IA32_EMULATION */
5141af86faSHiroshi Shimamoto 	struct ucontext_ia32 uc;
5241af86faSHiroshi Shimamoto 	char retcode[8];
5341af86faSHiroshi Shimamoto 	/* fp state follows here */
5441af86faSHiroshi Shimamoto };
55c85c2ff8SHiroshi Shimamoto #endif /* defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) */
56c85c2ff8SHiroshi Shimamoto 
57c85c2ff8SHiroshi Shimamoto #ifdef CONFIG_X86_64
589d389763SH. Peter Anvin 
5941af86faSHiroshi Shimamoto struct rt_sigframe {
6041af86faSHiroshi Shimamoto 	char __user *pretcode;
6141af86faSHiroshi Shimamoto 	struct ucontext uc;
6241af86faSHiroshi Shimamoto 	struct siginfo info;
6341af86faSHiroshi Shimamoto 	/* fp state follows here */
6441af86faSHiroshi Shimamoto };
659d389763SH. Peter Anvin 
669d389763SH. Peter Anvin #ifdef CONFIG_X86_X32_ABI
679d389763SH. Peter Anvin 
68b829d1beSBrian Gerst struct ucontext_x32 {
69b829d1beSBrian Gerst 	unsigned int	  uc_flags;
70b829d1beSBrian Gerst 	unsigned int 	  uc_link;
71b829d1beSBrian Gerst 	compat_stack_t	  uc_stack;
72b829d1beSBrian Gerst 	unsigned int	  uc__pad0;     /* needed for alignment */
73b829d1beSBrian Gerst 	struct sigcontext uc_mcontext;  /* the 64-bit sigcontext type */
74b829d1beSBrian Gerst 	compat_sigset_t	  uc_sigmask;	/* mask last for extensibility */
75b829d1beSBrian Gerst };
76b829d1beSBrian Gerst 
779d389763SH. Peter Anvin struct rt_sigframe_x32 {
789d389763SH. Peter Anvin 	u64 pretcode;
799d389763SH. Peter Anvin 	struct ucontext_x32 uc;
809d389763SH. Peter Anvin 	compat_siginfo_t info;
819d389763SH. Peter Anvin 	/* fp state follows here */
829d389763SH. Peter Anvin };
839d389763SH. Peter Anvin 
849d389763SH. Peter Anvin #endif /* CONFIG_X86_X32_ABI */
859d389763SH. Peter Anvin 
86c85c2ff8SHiroshi Shimamoto #endif /* CONFIG_X86_64 */
875c2628e8SHiroshi Shimamoto 
885c2628e8SHiroshi Shimamoto #endif /* _ASM_X86_SIGFRAME_H */
89