From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH 2/5] KVM: x86: Emulator performs code segment checks on read access Date: Mon, 6 Oct 2014 22:32:39 +0200 Message-ID: <20141006203238.GA4989@potion.brq.redhat.com> References: <1412287806-16016-1-git-send-email-namit@cs.technion.ac.il> <1412287806-16016-3-git-send-email-namit@cs.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: pbonzini@redhat.com, joro@8bytes.org, kvm@vger.kernel.org To: Nadav Amit Return-path: Received: from mx1.redhat.com ([209.132.183.28]:38488 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750991AbaJFUcu (ORCPT ); Mon, 6 Oct 2014 16:32:50 -0400 Content-Disposition: inline In-Reply-To: <1412287806-16016-3-git-send-email-namit@cs.technion.ac.il> Sender: kvm-owner@vger.kernel.org List-ID: 2014-10-03 01:10+0300, Nadav Amit: > When read access is performed using a readable code segment, the "con= forming" > and "non-conforming" checks should not be done. As a result, read us= ing > non-conforming readable code segment fails. >=20 > This is according to Intel SDM 5.6.1 ("Accessing Data in Code Segment= s"). (Checks are neccessarily true, except for non-conforming readable code, which is to be treated like a data segment.) > The fix is not to perform the "non-conforming" checks if the access i= s not a > fetch. (Because 'fetch' implies correct conditions and the rest is checked whe= n loading the segment,) > Signed-off-by: Nadav Amit > --- Reviewed-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > arch/x86/kvm/emulate.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > index a46207a..694dfa7 100644 > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -661,8 +661,8 @@ static int __linearize(struct x86_emulate_ctxt *c= txt, > goto bad; > } > cpl =3D ctxt->ops->cpl(ctxt); > - if (!(desc.type & 8)) { > - /* data segment */ > + if (!fetch) { > + /* data segment or readable code segment */ > if (cpl > desc.dpl) > goto bad; > } else if ((desc.type & 8) && !(desc.type & 4)) { > --=20 > 1.9.1 >=20 > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html