lkml.org 
[lkml]   [2019]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 2/3] KVM: x86: set ctxt->have_exception in x86_decode_insn()
Date
On Tue, 27 Aug 2019 07:53:58 -0700
Sean Christopherson <sean.j.christopherson@intel.com> wrote:

> On Tue, Aug 27, 2019 at 01:07:08PM +0000, Jan Dakinevich wrote:
> > x86_emulate_instruction() takes into account ctxt->have_exception flag
> > during instruction decoding, but in practice this flag is never set in
> > x86_decode_insn().
> >
> > Fixes: 6ea6e84 ("KVM: x86: inject exceptions produced by x86_decode_insn")
> > Cc: Denis Lunev <den@virtuozzo.com>
> > Cc: Roman Kagan <rkagan@virtuozzo.com>
> > Cc: Denis Plotnikov <dplotnikov@virtuozzo.com>
> > Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
> > ---
> > arch/x86/kvm/emulate.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> > index 6170ddf..f93880f 100644
> > --- a/arch/x86/kvm/emulate.c
> > +++ b/arch/x86/kvm/emulate.c
> > @@ -5395,6 +5395,8 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
> > ctxt->memopp->addr.mem.ea + ctxt->_eip);
> >
> > done:
> > + if (rc == X86EMUL_PROPAGATE_FAULT)
> > + ctxt->have_exception = true;
>
> We should add a sanity check or two on the vector since the emulator code
> goes all over the place, e.g. #UD should not be injected/propagated, and
> trap-like exceptions should not be handled/encountered during decode.
> Note, exception_type() also warns on illegal vectors.
>
> WARN_ON_ONCE(ctxt->exception.vector == UD_VECTOR ||
> exception_type(ctxt->exception.vector) == EXCPT_TRAP);

Ok.

>
> > return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK;
> > }
> >
> > --
> > 2.1.4
> >


--
Best regards
Jan Dakinevich

\
 
 \ /
  Last update: 2019-08-28 12:19    [W:0.055 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site