On 16 February 2018 at 21:56, Richard Henderson <richard.hender...@linaro.org> wrote: > The EXTRA record allows for additional space to be allocated > beyon what is currently reserved. Add code to emit and read > this record type. > > Nothing uses extra space yet. > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > ---
> @@ -1554,14 +1572,16 @@ static void target_restore_fpsimd_record(CPUARMState > *env, > static int target_restore_sigframe(CPUARMState *env, > struct target_rt_sigframe *sf) > { > - struct target_aarch64_ctx *ctx; > + struct target_aarch64_ctx *ctx, *extra = NULL; > struct target_fpsimd_context *fpsimd = NULL; > + uint64_t extra_datap = 0; > + bool used_extra = false; > > target_restore_general_frame(env, sf); > > ctx = (struct target_aarch64_ctx *)sf->uc.tuc_mcontext.__reserved; > while (ctx) { > - uint32_t magic, size; > + uint32_t magic, size, extra_size; > > __get_user(magic, &ctx->magic); > __get_user(size, &ctx->size); > @@ -1570,7 +1590,12 @@ static int target_restore_sigframe(CPUARMState *env, > if (size != 0) { > return 1; > } > - ctx = NULL; > + if (used_extra) { > + ctx = NULL; > + } else { > + ctx = extra; > + used_extra = true; > + } > continue; > > case TARGET_FPSIMD_MAGIC: > @@ -1580,6 +1605,17 @@ static int target_restore_sigframe(CPUARMState *env, > fpsimd = (struct target_fpsimd_context *)ctx; > break; > > + case TARGET_EXTRA_MAGIC: > + if (extra || size != sizeof(struct target_extra_context)) { > + return 1; > + } > + __get_user(extra_datap, > + &((struct target_extra_context *)ctx)->datap); > + __get_user(extra_size, > + &((struct target_extra_context *)ctx)->size); > + extra = lock_user(VERIFY_READ, extra_datap, extra_size, 0); > + break; > + > default: > /* Unknown record -- we certainly didn't generate it. > * Did we in fact get out of sync? > @@ -1595,6 +1631,9 @@ static int target_restore_sigframe(CPUARMState *env, > } > target_restore_fpsimd_record(env, fpsimd); > > + if (extra) { > + unlock_user(extra, extra_datap, 0); > + } This will fail to call unlock_user if the function returns early (eg because of failed magic-number checks or the FPSIMD record not being present). You don't need the "if (extra)" check -- unlock_user() is specified to do nothing if passed a NULL host_ptr. Otherwise looks good. thanks -- PMM