[CRIU] [PATCH 4/4] arch: Split get and save of user_regs_t and user_fpregs_t
Dmitry Safonov
dsafonov at virtuozzo.com
Mon Sep 26 05:06:32 PDT 2016
On 09/26/2016 11:25 AM, Pavel Emelyanov wrote:
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
> ---
> criu/arch/aarch64/crtools.c | 28 +++++---
> criu/arch/arm/crtools.c | 23 +++---
> criu/arch/ppc64/crtools.c | 117 +++++++++++++++++--------------
> criu/arch/x86/crtools.c | 165 ++++++++++++++++++++++++--------------------
> 4 files changed, 187 insertions(+), 146 deletions(-)
>
> diff --git a/criu/arch/aarch64/crtools.c b/criu/arch/aarch64/crtools.c
> index 9e0bd99..b8c6893 100644
> --- a/criu/arch/aarch64/crtools.c
> +++ b/criu/arch/aarch64/crtools.c
> @@ -78,14 +78,16 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
> return err;
> }
>
> +static int save_task_regs(CoreEntry *core,
> + user_regs_struct_t *regs, user_fpregs_struct_t *fpsimd)
semicolon at the end
>
> -#define assign_reg(dst, src, e) dst->e = (__typeof__(dst->e))(src).e
> +#define assign_reg(dst, src, e) dst->e = (__typeof__(dst->e))(src)->e
>
> int get_task_regs(pid_t pid, user_regs_struct_t regs, CoreEntry *core)
> {
> struct iovec iov;
> user_fpregs_struct_t fpsimd;
> - int i, ret;
> + int ret;
>
> pr_info("Dumping GP/FPU registers for %d\n", pid);
>
> @@ -103,6 +105,15 @@ int get_task_regs(pid_t pid, user_regs_struct_t regs, CoreEntry *core)
> goto err;
> }
>
> + ret = save_task_regs(core, ®s, &fpsimd);
> +err:
> + return ret;
> +}
> +
> +static int save_task_regs(CoreEntry *core,
> + user_regs_struct_t *regs, user_fpregs_struct_t *fpsimd)
> +{
> + int i;
>
> // Save the Aarch64 CPU state
> for (i = 0; i < 31; ++i)
> @@ -115,16 +126,13 @@ int get_task_regs(pid_t pid, user_regs_struct_t regs, CoreEntry *core)
> // Save the FP/SIMD state
> for (i = 0; i < 32; ++i)
> {
> - core->ti_aarch64->fpsimd->vregs[2*i] = fpsimd.vregs[i];
> - core->ti_aarch64->fpsimd->vregs[2*i + 1] = fpsimd.vregs[i] >> 64;
> + core->ti_aarch64->fpsimd->vregs[2*i] = fpsimd->vregs[i];
> + core->ti_aarch64->fpsimd->vregs[2*i + 1] = fpsimd->vregs[i] >> 64;
> }
> assign_reg(core->ti_aarch64->fpsimd, fpsimd, fpsr);
> assign_reg(core->ti_aarch64->fpsimd, fpsimd, fpcr);
>
> - ret = 0;
> -
> -err:
> - return ret;
> + return 0;
> }
>
> int arch_alloc_thread_info(CoreEntry *core)
> @@ -191,8 +199,8 @@ int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core)
> for (i = 0; i < 32; ++i)
> fpsimd->vregs[i] = (__uint128_t)core->ti_aarch64->fpsimd->vregs[2*i] |
> ((__uint128_t)core->ti_aarch64->fpsimd->vregs[2*i + 1] << 64);
> - assign_reg(fpsimd, *core->ti_aarch64->fpsimd, fpsr);
> - assign_reg(fpsimd, *core->ti_aarch64->fpsimd, fpcr);
> + assign_reg(fpsimd, core->ti_aarch64->fpsimd, fpsr);
> + assign_reg(fpsimd, core->ti_aarch64->fpsimd, fpcr);
>
> fpsimd->head.magic = FPSIMD_MAGIC;
> fpsimd->head.size = sizeof(*fpsimd);
> diff --git a/criu/arch/arm/crtools.c b/criu/arch/arm/crtools.c
> index 5325ff0..c3421b9 100644
> --- a/criu/arch/arm/crtools.c
> +++ b/criu/arch/arm/crtools.c
> @@ -80,7 +80,10 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
> return err;
> }
>
> -#define assign_reg(dst, src, e) dst->e = (__typeof__(dst->e))src.ARM_##e
> +static int save_task_regs(CoreEntry *core,
> + user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
here too ^
Other than that, looks good.
Reviewed-by: Dmitry Safonov <dsafonov at virtuozzo.com>
--
Dmitry
More information about the CRIU
mailing list