From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AD23C3A59F for ; Fri, 30 Aug 2019 01:06:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6332F2173E for ; Fri, 30 Aug 2019 01:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbfH3BGR (ORCPT ); Thu, 29 Aug 2019 21:06:17 -0400 Received: from mga03.intel.com ([134.134.136.65]:39895 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbfH3BGR (ORCPT ); Thu, 29 Aug 2019 21:06:17 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2019 18:06:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,445,1559545200"; d="scan'208";a="381844739" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by fmsmga006.fm.intel.com with ESMTP; 29 Aug 2019 18:06:15 -0700 Date: Thu, 29 Aug 2019 18:06:15 -0700 From: Sean Christopherson To: Jan Dakinevich Cc: "linux-kernel@vger.kernel.org" , Denis Lunev , Roman Kagan , Denis Plotnikov , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "x86@kernel.org" , "kvm@vger.kernel.org" Subject: Re: [PATCH v3 1/2] KVM: x86: always stop emulation on page fault Message-ID: <20190830010615.GC27970@linux.intel.com> References: <1567066988-23376-1-git-send-email-jan.dakinevich@virtuozzo.com> <1567066988-23376-2-git-send-email-jan.dakinevich@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1567066988-23376-2-git-send-email-jan.dakinevich@virtuozzo.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 29, 2019 at 08:23:18AM +0000, Jan Dakinevich wrote: > inject_emulated_exception() returns true if and only if nested page > fault happens. However, page fault can come from guest page tables > walk, either nested or not nested. In both cases we should stop an > attempt to read under RIP and give guest to step over its own page > fault handler. > > Fixes: 6ea6e84 ("KVM: x86: inject exceptions produced by x86_decode_insn") Commit ids should be at least 12 chars, the full tag should be Fixes: 6ea6e84309ca ("KVM: x86: inject exceptions produced by x86_decode_insn") You can force this in your git config, e.g. git config --global core.abbrev 12 Both patches in this series should probably have Cc: Reviewed-and-tested-by: Sean Christopherson > Cc: Denis Lunev > Cc: Roman Kagan > Cc: Denis Plotnikov > Signed-off-by: Jan Dakinevich > --- > arch/x86/kvm/x86.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index b4cfd78..6bf7b55 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6537,8 +6537,13 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, > if (reexecute_instruction(vcpu, cr2, write_fault_to_spt, > emulation_type)) > return EMULATE_DONE; > - if (ctxt->have_exception && inject_emulated_exception(vcpu)) > + if (ctxt->have_exception) { > + WARN_ON_ONCE(ctxt->exception.vector == UD_VECTOR); > + WARN_ON_ONCE(exception_type(ctxt->exception.vector) > + == EXCPT_TRAP); > + inject_emulated_exception(vcpu); > return EMULATE_DONE; > + } > if (emulation_type & EMULTYPE_SKIP) > return EMULATE_FAIL; > return handle_emulation_failure(vcpu, emulation_type); > -- > 2.1.4 >