On 09/07/2015 10:17, Richard Henderson wrote:
> 
> +void cpu_sync_bndcs_hf(CPUX86State *env)

s/hf/hflags/ :)

> +{
> +    uint32_t hflags = env->hflags;
> +    uint32_t bndcsr;
> +
> +    if ((hflags & HF_CPL_MASK) == 3) {
> +        bndcsr = env->bndcs_regs.cfgu;
> +    } else {
> +        bndcsr = env->msr_bndcfgs;
> +    }
> +
> +    if ((hflags & HF_OSXSAVE_MASK)
> +        && (env->xcr0 & XSTATE_BNDCSR)
> +        && (bndcsr & BNDCFG_ENABLE)) {
> +        hflags |= HF_MPX_EN_MASK;
> +    } else {
> +        hflags &= ~HF_MPX_EN_MASK;
> +    }
> +
> +    if (bndcsr & BNDCFG_BNDPRESERVE) {
> +        hflags |= HF_MPX_PR_MASK;
> +    } else {
> +        hflags &= ~HF_MPX_PR_MASK;
> +    }
> +
> +    env->hflags = hflags;
> +}

> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index f057982..27ae029 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -2186,6 +2186,11 @@ int kvm_arch_get_registers(CPUState *cs)
>      if (ret < 0) {
>          return ret;
>      }
> +
> +    /* ??? HFLAGS may be out of sync if any of the above error out.
> +       But there seems little point in recomputing this multiple times.  */
> +    cpu_sync_bndcs_hf(&cpu->env);

Why aren't you just using a goto, like

    if (ret < 0) {
        goto out;
    }
    ret = 0;
out:
    cpu_sync_bndcs_hf(&cpu->env);
    return ret;

>      return 0;

Reply via email to