From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: X86: generic MSRs save/restore Date: Fri, 13 Dec 2013 12:04:07 +0000 Message-ID: <52AAF7B7.9040904@citrix.com> References: <529F47D2020000780010A0E4@nat28.tlf.novell.com> <52AAE5B4020000780010CE4F@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <52AAE5B4020000780010CE4F@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , Jinsong Liu Cc: "xen-devel@lists.xen.org" , "keir@xen.org" , "Ian.Campbell@citrix.com" , "haoxudong.hao@gmail.com" List-Id: xen-devel@lists.xenproject.org On 13/12/2013 09:47, Jan Beulich wrote: >>>> On 13.12.13 at 08:57, "Liu, Jinsong" wrote: >> --- a/xen/arch/x86/hvm/vmx/vmx.c >> +++ b/xen/arch/x86/hvm/vmx/vmx.c >> @@ -580,6 +580,50 @@ static int vmx_load_vmcs_ctxt(struct vcp >> return 0; >> } >> >> +static unsigned int __init vmx_init_msr(void) >> +{ >> + return !!cpu_has_mpx; >> +} >> + >> +static void vmx_save_msr(struct vcpu *v, struct hvm_msr *ctxt) >> +{ >> + vmx_vmcs_enter(v); >> + >> + if ( cpu_has_mpx ) >> + { >> + __vmread(GUEST_BNDCFGS, &ctxt->msr[ctxt->count].val); >> + if ( ctxt->msr[ctxt->count].val ) >> >> >> Isn't it better to remove if()? > Definitely not: That way, if the hardware support MPX but the > guest never used it, restoring the guest on an MPX-incapable > host will be possible. And when the MSR is zero, restoring on an > MPX-capable host will be correct too, as the respective VMCS > field starts out zeroed. > > Jan > Furthermore, this looks as if is heading straight for an ABI breakage. What guarantee is that that the MSRs shall aways be saved and restored in this specific order forever more in the future? I think ctxt->count needs to be replaced with an ABI constant. ~Andrew