18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_SIGFRAME_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_SIGFRAME_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <uapi/asm/sigcontext.h>
68c2ecf20Sopenharmony_ci#include <asm/siginfo.h>
78c2ecf20Sopenharmony_ci#include <asm/ucontext.h>
88c2ecf20Sopenharmony_ci#include <linux/compat.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_32
118c2ecf20Sopenharmony_ci#define sigframe_ia32		sigframe
128c2ecf20Sopenharmony_ci#define rt_sigframe_ia32	rt_sigframe
138c2ecf20Sopenharmony_ci#define ucontext_ia32		ucontext
148c2ecf20Sopenharmony_ci#else /* !CONFIG_X86_32 */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifdef CONFIG_IA32_EMULATION
178c2ecf20Sopenharmony_ci#include <asm/ia32.h>
188c2ecf20Sopenharmony_ci#endif /* CONFIG_IA32_EMULATION */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#endif /* CONFIG_X86_32 */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
238c2ecf20Sopenharmony_cistruct sigframe_ia32 {
248c2ecf20Sopenharmony_ci	u32 pretcode;
258c2ecf20Sopenharmony_ci	int sig;
268c2ecf20Sopenharmony_ci	struct sigcontext_32 sc;
278c2ecf20Sopenharmony_ci	/*
288c2ecf20Sopenharmony_ci	 * fpstate is unused. fpstate is moved/allocated after
298c2ecf20Sopenharmony_ci	 * retcode[] below. This movement allows to have the FP state and the
308c2ecf20Sopenharmony_ci	 * future state extensions (xsave) stay together.
318c2ecf20Sopenharmony_ci	 * And at the same time retaining the unused fpstate, prevents changing
328c2ecf20Sopenharmony_ci	 * the offset of extramask[] in the sigframe and thus prevent any
338c2ecf20Sopenharmony_ci	 * legacy application accessing/modifying it.
348c2ecf20Sopenharmony_ci	 */
358c2ecf20Sopenharmony_ci	struct _fpstate_32 fpstate_unused;
368c2ecf20Sopenharmony_ci	unsigned int extramask[1];
378c2ecf20Sopenharmony_ci	char retcode[8];
388c2ecf20Sopenharmony_ci	/* fp state follows here */
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistruct rt_sigframe_ia32 {
428c2ecf20Sopenharmony_ci	u32 pretcode;
438c2ecf20Sopenharmony_ci	int sig;
448c2ecf20Sopenharmony_ci	u32 pinfo;
458c2ecf20Sopenharmony_ci	u32 puc;
468c2ecf20Sopenharmony_ci#ifdef CONFIG_IA32_EMULATION
478c2ecf20Sopenharmony_ci	compat_siginfo_t info;
488c2ecf20Sopenharmony_ci#else /* !CONFIG_IA32_EMULATION */
498c2ecf20Sopenharmony_ci	struct siginfo info;
508c2ecf20Sopenharmony_ci#endif /* CONFIG_IA32_EMULATION */
518c2ecf20Sopenharmony_ci	struct ucontext_ia32 uc;
528c2ecf20Sopenharmony_ci	char retcode[8];
538c2ecf20Sopenharmony_ci	/* fp state follows here */
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci#endif /* defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistruct rt_sigframe {
608c2ecf20Sopenharmony_ci	char __user *pretcode;
618c2ecf20Sopenharmony_ci	struct ucontext uc;
628c2ecf20Sopenharmony_ci	struct siginfo info;
638c2ecf20Sopenharmony_ci	/* fp state follows here */
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_X32_ABI
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistruct ucontext_x32 {
698c2ecf20Sopenharmony_ci	unsigned int	  uc_flags;
708c2ecf20Sopenharmony_ci	unsigned int 	  uc_link;
718c2ecf20Sopenharmony_ci	compat_stack_t	  uc_stack;
728c2ecf20Sopenharmony_ci	unsigned int	  uc__pad0;     /* needed for alignment */
738c2ecf20Sopenharmony_ci	struct sigcontext uc_mcontext;  /* the 64-bit sigcontext type */
748c2ecf20Sopenharmony_ci	compat_sigset_t	  uc_sigmask;	/* mask last for extensibility */
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistruct rt_sigframe_x32 {
788c2ecf20Sopenharmony_ci	u64 pretcode;
798c2ecf20Sopenharmony_ci	struct ucontext_x32 uc;
808c2ecf20Sopenharmony_ci	compat_siginfo_t info;
818c2ecf20Sopenharmony_ci	/* fp state follows here */
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#endif /* CONFIG_X86_X32_ABI */
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#endif /* CONFIG_X86_64 */
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#endif /* _ASM_X86_SIGFRAME_H */
89