From patchwork Thu Dec 20 18:28:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adalbert_Laz=C4=83r?= X-Patchwork-Id: 10739307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B14313B5 for ; Thu, 20 Dec 2018 18:36:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87FFC28E58 for ; Thu, 20 Dec 2018 18:36:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7681328F39; Thu, 20 Dec 2018 18:36:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 352CA28E58 for ; Thu, 20 Dec 2018 18:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389320AbeLTSgD (ORCPT ); Thu, 20 Dec 2018 13:36:03 -0500 Received: from mx01.bbu.dsd.mx.bitdefender.com ([91.199.104.161]:44322 "EHLO mx01.bbu.dsd.mx.bitdefender.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389293AbeLTSgC (ORCPT ); Thu, 20 Dec 2018 13:36:02 -0500 Received: from smtp.bitdefender.com (smtp02.buh.bitdefender.net [10.17.80.76]) by mx01.bbu.dsd.mx.bitdefender.com (Postfix) with ESMTPS id 0BB35305FFC1; Thu, 20 Dec 2018 20:29:38 +0200 (EET) Received: from host.bbu.bitdefender.biz (unknown [10.10.193.111]) by smtp.bitdefender.com (Postfix) with ESMTPSA id 008BC304BD6A; Thu, 20 Dec 2018 20:29:38 +0200 (EET) From: =?utf-8?q?Adalbert_Laz=C4=83r?= To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , =?utf-8?q?Mihai_Don?= =?utf-8?q?=C8=9Bu?= , =?utf-8?q?Adalbert_Laz=C4=83r?= Subject: [RFC PATCH v5 20/20] kvm: x86: hook in kvmi_trap_event() Date: Thu, 20 Dec 2018 20:28:50 +0200 Message-Id: <20181220182850.4579-21-alazar@bitdefender.com> In-Reply-To: <20181220182850.4579-1-alazar@bitdefender.com> References: <20181220182850.4579-1-alazar@bitdefender.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mihai DONTU Inform the guest introspection tool that the exception (from a previous KVMI_INJECT_EXCEPTION command) was not successfully injected. It can happen for the introspection tool to queue a pagefault but have it overwritten by an interrupt picked up during guest reentry. kvmi_trap_event() is used to inform the tool when such a situation has been detected. Signed-off-by: Mihai Donțu --- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6d5f801e4797..64572f7ec689 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7773,6 +7773,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) } } + if (kvmi_lost_exception(vcpu)) + kvmi_trap_event(vcpu); + r = kvm_mmu_reload(vcpu); if (unlikely(r)) { goto cancel_injection;