From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDBjA-0003Th-Fo for qemu-devel@nongnu.org; Thu, 09 Jul 2015 09:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDBj7-0007xi-AH for qemu-devel@nongnu.org; Thu, 09 Jul 2015 09:19:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDBj7-0007xW-4j for qemu-devel@nongnu.org; Thu, 09 Jul 2015 09:18:57 -0400 References: <1436429849-18052-1-git-send-email-rth@twiddle.net> <1436429849-18052-6-git-send-email-rth@twiddle.net> From: Paolo Bonzini Message-ID: <559E74BD.8050503@redhat.com> Date: Thu, 9 Jul 2015 15:18:53 +0200 MIME-Version: 1.0 In-Reply-To: <1436429849-18052-6-git-send-email-rth@twiddle.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 05/14] target-i386: Enable control registers for MPX List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson , qemu-devel@nongnu.org Cc: ehabkost@redhat.com 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;