From patchwork Thu Jun 15 12:03:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9788721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2777F60384 for ; Thu, 15 Jun 2017 12:03:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C388285EA for ; Thu, 15 Jun 2017 12:03:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F36ED285EF; Thu, 15 Jun 2017 12:03:09 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 9B536285EA for ; Thu, 15 Jun 2017 12:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752311AbdFOMDH (ORCPT ); Thu, 15 Jun 2017 08:03:07 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:36539 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751902AbdFOMDG (ORCPT ); Thu, 15 Jun 2017 08:03:06 -0400 Received: by mail-qt0-f194.google.com with SMTP id s33so2612591qtg.3 for ; Thu, 15 Jun 2017 05:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=G3xrRf0gzXlBz5iRhuH7uiz2VqFIXHr4WnhXG2WJ+zE=; b=dAQk48tI9VEDZSm7x78jTC8x8u24KNgUlDnfwJ/iE7sDGvJRnfHTY9YbQcK3IMZ2GY GhwAtWtNL4o7RLJMw6uYGwTSCP18vcsNwqfFC91WZJlnOQcJ+BLzVZHCoH12MU/EDWVv EyC/D7BpqCS5xNKYFJlXJ/jnnQilYLNV0kCPmCjJ2rpnIrF51EC4jtFnYRU1W/7g6WgI XAFIFKZqWK0tS1EaHF2O7U15q3QPCMqler7RMwm14KIl6eU5I2UzRdUi4XVABPW9rvKy BDSkHTznap5Wc+TlCEIAIQi/KEIvCnlWP2DjoALvEymV41wQf4ayUwbtSte504jPMqru 7Erg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G3xrRf0gzXlBz5iRhuH7uiz2VqFIXHr4WnhXG2WJ+zE=; b=Ufp1hT6GTHv7BRZ+nB4wbhYJOiRk049ekaTi/ZtedRDdNafKyCqIitjGiyau7dSA47 OXo3OdQFUewfW9av7lSHry1sDBnH26WAZ8C/BU5bvDYFcVE8jGRKD5t9P6Ms0zZVZGa+ DTt4ykpBern2FlAp56TOs07VbjtIfLPragctilSVG3kuJSvIaVHTaOll8eitaDc5x7Mu m6wImqT48/bNFaAiMvUyAGBnxyIPK0G6Am5KueceZQB8yuwGsF+CYcvCzLJeP/p+Qm/1 mjRai9FxCtGBsOSBwAXB1+2UDXJZDXc0O7qXnTjGDOH2LtTckZZmwbbWuhh0ZTpQhbxD O2Ug== X-Gm-Message-State: AKS2vOysk8lF1BiJfEPtxC9/4eLVvqHBFDTs78COLRxq2Vwjq5rXQ4CX IdcADF11o6vcF9a3H+g= X-Received: by 10.80.143.36 with SMTP id 33mr3382028edy.68.1497528185480; Thu, 15 Jun 2017 05:03:05 -0700 (PDT) Received: from [192.168.10.165] (94-39-191-51.adsl-ull.clienti.tiscali.it. [94.39.191.51]) by smtp.googlemail.com with ESMTPSA id k17sm1813589eda.24.2017.06.15.05.03.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jun 2017 05:03:04 -0700 (PDT) Subject: Re: [PATCH 0/4] KVM: SVM: improve NMI window singlestep To: Ladi Prosek , KVM list References: <20170615112032.15812-1-lprosek@redhat.com> From: Paolo Bonzini Message-ID: <9586f0ae-d46e-97d8-227b-de9914581a06@redhat.com> Date: Thu, 15 Jun 2017 14:03:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170615112032.15812-1-lprosek@redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 15/06/2017 13:20, Ladi Prosek wrote: > NMI window singlestep kind of works with these patches because it's meant > only for short sequences (I believe that the original intention was to > step over an IRET but I doubt it's that simple anymore) Yes, it was meant to step over an IRET or an interrupt shadow. One extra case that may cause NMI singlestep these days is GIF=0, but that is also solved easily: Paolo > so we can get > away with half-butting it. In particular, it's unlikely that the guest > would set the TRAP flag while the NMI window is closed. Properly handling > KVM_GUESTDBG_SINGLESTEP would likely involve intercepting PUSHF & POPF, > clearing the TRAP flag from the stack on interrupt entry, and possibly more. diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index d1efe2c62b3f..15a2f7f8e539 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4622,6 +4622,9 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu) if ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_IRET_MASK)) == HF_NMI_MASK) return; /* IRET will cause a vm exit */ + if ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_GIF_MASK)) + == HF_NMI_MASK) + return; /* STGI will cause a vm exit */ so you could include this change in your series.