From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 3/4] x86/SVM: don't exceed segment limit when fetching instruction bytes Date: Wed, 11 Nov 2015 16:01:38 +0000 Message-ID: <56436662.9020003@citrix.com> References: <5642390402000078000B384D@prv-mh.provo.novell.com> <56423A0202000078000B3861@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZwXqE-00088m-Vk for xen-devel@lists.xenproject.org; Wed, 11 Nov 2015 16:01:47 +0000 In-Reply-To: <56423A0202000078000B3861@prv-mh.provo.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 , xen-devel Cc: Boris Ostrovsky , Aravind Gopalakrishnan , suravee.suthikulpanit@amd.com List-Id: xen-devel@lists.xenproject.org On 10/11/15 17:40, Jan Beulich wrote: > Also consistently use the vmcb local variable whenever possible. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper with one trivial fix. > > --- a/xen/arch/x86/hvm/svm/emulate.c > +++ b/xen/arch/x86/hvm/svm/emulate.c > @@ -47,12 +47,17 @@ static unsigned int is_prefix(u8 opc) > return 0; > } > > -static unsigned long svm_rip2pointer(struct vcpu *v) > +static unsigned long svm_rip2pointer(struct vcpu *v, unsigned long *limit) > { > struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; > - unsigned long p = vmcb->cs.base + guest_cpu_user_regs()->eip; > + unsigned long p = vmcb->cs.base + vmcb->rip; > + > if ( !(vmcb->cs.attr.fields.l && hvm_long_mode_enabled(v)) ) > + { > + *limit = vmcb->cs.limit; > return (u32)p; /* mask to 32 bits */ > + } > + *limit = ~0UL; > return p; > } > > @@ -125,11 +130,10 @@ static const u8 *const opc_bytes[INSTR_M > [INSTR_INVLPGA] = OPCODE_INVLPGA, > }; > > -static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len) > +static bool_t fetch(const struct vmcb_struct *vmcb, u8 *buf, > + unsigned long addr, unsigned int len) (mis)indentation of addr ~Andrew