[CRIU] [PATCH 1/4] compel: arch, x86 -- Make rt_sigcontext_32 members being close to kernel

Dmitry Safonov dsafonov at virtuozzo.com
Tue Feb 14 06:30:56 PST 2017


On 02/14/2017 01:26 PM, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>

Don't mind about this change, but I remember why I introduced it the
other way then in kernel: I didn't need to handle selectors partly.
And that simplified macro to copy them:

#define CPREG32(d)	f->compat.uc.uc_mcontext.d = r->d
...
static void restore_compat_gpregs(struct rt_sigframe *f, 
UserX86RegsEntry *r)
{
	CPREG32(gs);
	CPREG32(fs);
	CPREG32(es);
	CPREG32(ds);

So, if I don't miss anything - this will be broken afterwards.
(not sure, why compiler didn't warn you here)
Could you fix registers copy then?

> ---
>  compel/arch/x86/src/lib/include/uapi/asm/sigframe.h | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
> index 21cd341c0393..619935b0e1e9 100644
> --- a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
> +++ b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
> @@ -41,10 +41,10 @@ struct rt_sigcontext {
>  };
>
>  struct rt_sigcontext_32 {
> -	uint32_t			gs;
> -	uint32_t			fs;
> -	uint32_t			es;
> -	uint32_t			ds;
> +	uint16_t			gs, __gsh;
> +	uint16_t			fs, __fsh;
> +	uint16_t			es, __esh;
> +	uint16_t			ds, __dsh;
>  	uint32_t			di;
>  	uint32_t			si;
>  	uint32_t			bp;
> @@ -56,11 +56,10 @@ struct rt_sigcontext_32 {
>  	uint32_t			trapno;
>  	uint32_t			err;
>  	uint32_t			ip;
> -	uint32_t			cs;
> +	uint16_t			cs, __csh;
>  	uint32_t			flags;
>  	uint32_t			sp_at_signal;
> -	uint32_t			ss;
> -
> +	uint16_t			ss, __ssh;
>  	uint32_t			fpstate;
>  	uint32_t			oldmask;
>  	uint32_t			cr2;
>


-- 
              Dmitry


More information about the CRIU mailing list