mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
ia32: Add compatible sigmask to sigframe
It has a different alignment - rework ugly macro RT_SIGFRAME_UC_SIGMASK into helpers. Fixes: #666 Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
committed by
Andrei Vagin
parent
d52720a49d
commit
7905b9f65e
@@ -61,4 +61,9 @@ struct cr_sigcontext {
|
||||
#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_CONTEXT(rt_sigframe)->fpsimd)
|
||||
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
|
||||
|
||||
#define rt_sigframe_erase_sigset(sigframe) \
|
||||
memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
|
||||
#define rt_sigframe_copy_sigset(sigframe, from) \
|
||||
memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t))
|
||||
|
||||
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
|
||||
|
@@ -82,4 +82,9 @@ struct rt_sigframe {
|
||||
#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_SIGFRAME(rt_sigframe)->vfp)
|
||||
#define RT_SIGFRAME_OFFSET(rt_sigframe) 0
|
||||
|
||||
#define rt_sigframe_erase_sigset(sigframe) \
|
||||
memset(&sigframe->sig.uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
|
||||
#define rt_sigframe_copy_sigset(sigframe, from) \
|
||||
memcpy(&sigframe->sig.uc.uc_sigmask, from, sizeof(k_rtsigset_t))
|
||||
|
||||
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
|
||||
|
@@ -63,6 +63,11 @@ struct rt_sigframe {
|
||||
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
|
||||
#define RT_SIGFRAME_FPU(rt_sigframe) (&(rt_sigframe)->uc.uc_mcontext)
|
||||
|
||||
#define rt_sigframe_erase_sigset(sigframe) \
|
||||
memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
|
||||
#define rt_sigframe_copy_sigset(sigframe, from) \
|
||||
memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t))
|
||||
|
||||
#define MSR_TMA (1UL<<34) /* bit 29 Trans Mem state: Transactional */
|
||||
#define MSR_TMS (1UL<<33) /* bit 30 Trans Mem state: Suspended */
|
||||
#define MSR_TM (1UL<<32) /* bit 31 Trans Mem Available */
|
||||
|
@@ -72,4 +72,9 @@ struct rt_sigframe {
|
||||
#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->uc.uc_mcontext.regs.psw.addr
|
||||
#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1)
|
||||
|
||||
#define rt_sigframe_erase_sigset(sigframe) \
|
||||
memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t))
|
||||
#define rt_sigframe_copy_sigset(sigframe, from) \
|
||||
memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t))
|
||||
|
||||
#endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <compel/asm/fpu.h>
|
||||
#include <compel/plugins/std/syscall-codes.h>
|
||||
@@ -75,6 +76,7 @@ struct rt_sigcontext_32 {
|
||||
|
||||
typedef uint32_t compat_uptr_t;
|
||||
typedef uint32_t compat_size_t;
|
||||
typedef uint32_t compat_sigset_word;
|
||||
|
||||
typedef struct compat_siginfo {
|
||||
int si_signo;
|
||||
@@ -89,12 +91,20 @@ typedef struct compat_sigaltstack {
|
||||
compat_size_t ss_size;
|
||||
} compat_stack_t;
|
||||
|
||||
#define _COMPAT_NSIG 64
|
||||
#define _COMPAT_NSIG_BPW 32
|
||||
#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
|
||||
|
||||
typedef struct {
|
||||
compat_sigset_word sig[_COMPAT_NSIG_WORDS];
|
||||
} compat_sigset_t;
|
||||
|
||||
struct ucontext_ia32 {
|
||||
unsigned int uc_flags;
|
||||
unsigned int uc_link;
|
||||
compat_stack_t uc_stack;
|
||||
struct rt_sigcontext_32 uc_mcontext;
|
||||
k_rtsigset_t uc_sigmask; /* mask last for extensibility */
|
||||
compat_sigset_t uc_sigmask; /* mask last for extensibility */
|
||||
};
|
||||
|
||||
struct rt_sigframe_ia32 {
|
||||
@@ -127,10 +137,28 @@ struct rt_sigframe {
|
||||
bool is_native;
|
||||
};
|
||||
|
||||
#define RT_SIGFRAME_UC_SIGMASK(rt_sigframe) \
|
||||
((rt_sigframe->is_native) ? \
|
||||
(&rt_sigframe->native.uc.uc_sigmask) : \
|
||||
((k_rtsigset_t *)(void *)&rt_sigframe->compat.uc.uc_sigmask))
|
||||
static inline
|
||||
void rt_sigframe_copy_sigset(struct rt_sigframe *to, k_rtsigset_t *from)
|
||||
{
|
||||
size_t sz = sizeof(k_rtsigset_t);
|
||||
|
||||
BUILD_BUG_ON(sz != sizeof(compat_sigset_t));
|
||||
if (to->is_native)
|
||||
memcpy(&to->native.uc.uc_sigmask, from, sz);
|
||||
else
|
||||
memcpy(&to->compat.uc.uc_sigmask, from, sz);
|
||||
}
|
||||
|
||||
static inline
|
||||
void rt_sigframe_erase_sigset(struct rt_sigframe *sigframe)
|
||||
{
|
||||
size_t sz = sizeof(k_rtsigset_t);
|
||||
|
||||
if (sigframe->is_native)
|
||||
memset(&sigframe->native.uc.uc_sigmask, 0, sz);
|
||||
else
|
||||
memset(&sigframe->compat.uc.uc_sigmask, 0, sz);
|
||||
}
|
||||
|
||||
#define RT_SIGFRAME_REGIP(rt_sigframe) \
|
||||
((rt_sigframe->is_native) ? \
|
||||
|
@@ -116,7 +116,7 @@ void compel_convert_from_fxsr(struct user_i387_ia32_struct *env,
|
||||
struct i387_fxsave_struct *fxsave)
|
||||
{
|
||||
struct fpxreg *from = (struct fpxreg *)&fxsave->st_space[0];
|
||||
struct fpreg *to = (struct fpreg *)&env->st_space[0];
|
||||
struct fpreg *to = (struct fpreg *)env->st_space;
|
||||
int i;
|
||||
|
||||
env->cwd = fxsave->cwd | 0xffff0000u;
|
||||
|
@@ -1130,15 +1130,9 @@ static int save_regs_plain(void *to, user_regs_struct_t *r, user_fpregs_struct_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef RT_SIGFRAME_UC_SIGMASK
|
||||
#define RT_SIGFRAME_UC_SIGMASK(sigframe) \
|
||||
(k_rtsigset_t*)(void *)&RT_SIGFRAME_UC(sigframe)->uc_sigmask
|
||||
#endif
|
||||
|
||||
static int make_sigframe_plain(void *from, struct rt_sigframe *f, struct rt_sigframe *rtf, k_rtsigset_t *b)
|
||||
{
|
||||
struct plain_regs_struct *prs = from;
|
||||
k_rtsigset_t *blk_sigset;
|
||||
|
||||
/*
|
||||
* Make sure it's zeroified.
|
||||
@@ -1148,11 +1142,8 @@ static int make_sigframe_plain(void *from, struct rt_sigframe *f, struct rt_sigf
|
||||
if (sigreturn_prep_regs_plain(f, &prs->regs, &prs->fpregs))
|
||||
return -1;
|
||||
|
||||
blk_sigset = RT_SIGFRAME_UC_SIGMASK(f);
|
||||
if (b)
|
||||
memcpy(blk_sigset, b, sizeof(k_rtsigset_t));
|
||||
else
|
||||
memset(blk_sigset, 0, sizeof(k_rtsigset_t));
|
||||
rt_sigframe_copy_sigset(f, b);
|
||||
|
||||
if (RT_SIGFRAME_HAS_FPU(f)) {
|
||||
if (sigreturn_prep_fpu_frame_plain(f, rtf))
|
||||
|
@@ -18,18 +18,11 @@ static inline void setup_sas(struct rt_sigframe* sigframe, ThreadSasEntry *sas)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef RT_SIGFRAME_UC_SIGMASK
|
||||
#define RT_SIGFRAME_UC_SIGMASK(sigframe) \
|
||||
(k_rtsigset_t*)&RT_SIGFRAME_UC(sigframe)->uc_sigmask
|
||||
#endif
|
||||
|
||||
int construct_sigframe(struct rt_sigframe *sigframe,
|
||||
struct rt_sigframe *rsigframe,
|
||||
k_rtsigset_t *blkset,
|
||||
CoreEntry *core)
|
||||
{
|
||||
k_rtsigset_t *blk_sigset;
|
||||
|
||||
/*
|
||||
* Copy basic register set in the first place: this will set
|
||||
* rt_sigframe type: native/compat.
|
||||
@@ -37,11 +30,10 @@ int construct_sigframe(struct rt_sigframe *sigframe,
|
||||
if (restore_gpregs(sigframe, CORE_THREAD_ARCH_INFO(core)->gpregs))
|
||||
return -1;
|
||||
|
||||
blk_sigset = RT_SIGFRAME_UC_SIGMASK(sigframe);
|
||||
if (blkset)
|
||||
memcpy(blk_sigset, blkset, sizeof(k_rtsigset_t));
|
||||
rt_sigframe_copy_sigset(sigframe, blkset);
|
||||
else
|
||||
memset(blk_sigset, 0, sizeof(k_rtsigset_t));
|
||||
rt_sigframe_erase_sigset(sigframe);
|
||||
|
||||
if (restore_fpu(sigframe, core))
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user