Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5998690ybl; Tue, 27 Aug 2019 12:51:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKNbsY65gyCNQhI10FrwtyCxf6b+/TKa7de5kAdgx2NSJ5F57g0zxBAI3A99MCvEYa+qaL X-Received: by 2002:a17:902:820f:: with SMTP id x15mr539476pln.229.1566935467239; Tue, 27 Aug 2019 12:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566935467; cv=none; d=google.com; s=arc-20160816; b=SyfruTEY3U7uH3orJdcIlQUXIuy7WG4qwtQXaMg7nANvdQL/uYUfnCs2MauDtBGN84 BSG6sKa6p+dvBJ4KNNMZAAxnGtAneIiEjlt/u4F8bn5pT6XRQxHeBKIGXpb1nYxZKMuL I4VscArkbhFR5v+YUbJQQds/VSjUkg/gq7KUwxuiu+O7cBuhjkAS5yTdpvZSURl6r/37 g+2GuhduUeT9tXOA3iGBvECgDD33l4vnw+wSG6oN+WM+Cyf0/EdJ4nOzB962AGnAwmTB U8pYsZi6jSgGYB2jVuvMHsgp7f+5m6vQ94jVNA/5iaLZCnRi+KgO/Uk8xMGLNAIsD7oH 5K9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=81oSPt7tAk5Pozb/y6kl8WLH2MwkNwfze8gQsNVkJZU=; b=FP3VupXRug77JZDXB2W1owmjWh5wrgYhmpx8b5sa9t2/osnamDEN/bXud2JuncJXTH gYAeFCMFJ/qTWRgGA/jTn62OrLxyl7x4TYbBpti7X9FaAIeF09yCuqG2kXFXHazENvHY A949wQYofgF3Hm/XUUZxlUvy7GuBrE/m+S0J9mogArq6RmnJN1qL/opHA3M3NpD50fLe Yo+Db7KDcciVvXVW3acKoAg71yicpgYH3TrExVAY1sF0NHDz929j56pNLrFKZVQMWNzy 7I7ypbsgKKD0809OH8ELYWiUnh4nEgYHQLW2ZDGQbjIU31HHlPaagziprhJ2G0PIYfjC 6V4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si348425plu.432.2019.08.27.12.50.51; Tue, 27 Aug 2019 12:51:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731113AbfH0Tta (ORCPT + 99 others); Tue, 27 Aug 2019 15:49:30 -0400 Received: from mga14.intel.com ([192.55.52.115]:27796 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfH0Tta (ORCPT ); Tue, 27 Aug 2019 15:49:30 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 12:49:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,438,1559545200"; d="scan'208";a="197377356" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by fmsmga001.fm.intel.com with ESMTP; 27 Aug 2019 12:49:29 -0700 Date: Tue, 27 Aug 2019 12:49:28 -0700 From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Nadav Amit , Andy Lutomirski Subject: Re: [PATCH] KVM: x86: Don't update RIP or do single-step on faulting emulation Message-ID: <20190827194928.GH27459@linux.intel.com> References: <20190823205544.24052-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Aug 27, 2019 at 12:12:51PM -0700, Jim Mattson wrote: > On Fri, Aug 23, 2019 at 1:55 PM Sean Christopherson > wrote: > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -6611,12 +6611,13 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, > > unsigned long rflags = kvm_x86_ops->get_rflags(vcpu); > > toggle_interruptibility(vcpu, ctxt->interruptibility); > > vcpu->arch.emulate_regs_need_sync_to_vcpu = false; > > - kvm_rip_write(vcpu, ctxt->eip); > > - if (r == EMULATE_DONE && ctxt->tf) > > - kvm_vcpu_do_singlestep(vcpu, &r); > > if (!ctxt->have_exception || > > - exception_type(ctxt->exception.vector) == EXCPT_TRAP) > > + exception_type(ctxt->exception.vector) == EXCPT_TRAP) { > > NYC, but... > > I don't think this check for "exception_type" is quite right. A > general detect fault (which can be synthesized by check_dr_read) is > mischaracterized by exception_type() as a trap. Or maybe I'm missing > something? (I often am.) Pretty sure you're not missing anything. And while we're poking holes in #DB emulation, int1/icebp isn't emulated correctly as it should be reinjected with INTR_TYPE_PRIV_SW_EXCEPTION, not as a INTR_TYPE_HARD_EXCEPTION. The CPU automically clears DR7.GD on #DB, unless the #DB is due to int1...