Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp172363imd; Wed, 31 Oct 2018 16:46:38 -0700 (PDT) X-Google-Smtp-Source: AJdET5fwC40H0TZVHsIGS0weAExdBLpmhkA/RixTNz3uG0jvNJWv42q9cAjTW3c0/aBBUN45gl/1 X-Received: by 2002:a17:902:4324:: with SMTP id i33-v6mr5424414pld.253.1541029598145; Wed, 31 Oct 2018 16:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029598; cv=none; d=google.com; s=arc-20160816; b=xv/HaelVRZjNr8FitGTT72KwevnWrjMYZuRrvhdE6gA8au0gyDg0mC26ROTJ+/+4h4 Hwwyye6ksal+vZ8HI+eZxjDC08FFyjNfaLoF28fSquoXAHj7qw/WvAk6vqVw7GHCcYyY 9SUzARJXgLgr0j2BPAvbNUHmh3wPUjTH4n5KwczBQjk6mxI77lu80L+wgw8ov/i2m1Eq WmapjpobsS5q5cM5zbdgOLJ2k5EMaswd6Y/emTviaOuE5DpZNklslKlwQHQ+h9d1GdRJ pAZFFpzTHVwjQlJO7fCOqFO3typy6e/euBU973r+49aqtvDnfUAfEI8mWzSEmMY93Q+6 ymOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=bSY+hfjxKoUB/lFm6ezMXIGjUvBBbgwBqSS35xlHRN0=; b=yizucCEDw5O6+G9FI7dTqPc2B23eWTTrQzT8GuwF2jvhQz9N1IjuqO0XHDsPqMLcQt cmqguhefoSkmJIj+tUzOKUdgl3gcjCLsdfdQwyge+gzk8ragog1gge+Zzanco/sRlnzw VJmGA73VqGhXCUwQwxY2Og/sNsFiq3ArB86XOu/WlJ3L7cy0ptiikgrSPFlQpalN3Ib9 xznp3QU7rqAs0HR+kqqCHjefp4lMNYlbyRJ7/GWMCaKDseLJIk1eEquReCLCuxSjY2eF zwBGbiUs4ZIhO7jyodRLUzsmXiZQ5MQNrG6kOj5/Kaaf6ElY+eH6EQd1IuQTmMBzY1J0 ie7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TDDwOXyQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3-v6si15420785plb.370.2018.10.31.16.46.23; Wed, 31 Oct 2018 16:46:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b=TDDwOXyQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728793AbeKAIHU (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:54918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbeKAIHT (ORCPT ); Thu, 1 Nov 2018 04:07:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 11F7220840; Wed, 31 Oct 2018 23:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027228; bh=PxbQiwHKrCR0NH6ar55FXMfvmuTVUkgBgwnl4i46YxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TDDwOXyQYXW77lsbjSkwQ51VmSU+HtugDuUvrJlyNfiE9JlFlyoWDUXldK8CgoTBx +K2uGumTpEFBcGpSNA9hzWeFrEH9jusiLLEdVQBOINwHB9XWMTbYUE1Q3D8Jy8uMTn AQXo/z0gj0Bg2J2pc3zcQBWDRVLtYCzybGOdx+wk= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jim Mattson , Paolo Bonzini , Sasha Levin Subject: [PATCH AUTOSEL 4.19 095/146] KVM: nVMX: Clear reserved bits of #DB exit qualification Date: Wed, 31 Oct 2018 19:04:50 -0400 Message-Id: <20181031230541.28822-95-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Mattson [ Upstream commit cfb634fe3052aefc4e1360fa322018c9a0b49755 ] According to volume 3 of the SDM, bits 63:15 and 12:4 of the exit qualification field for debug exceptions are reserved (cleared to 0). However, the SDM is incorrect about bit 16 (corresponding to DR6.RTM). This bit should be set if a debug exception (#DB) or a breakpoint exception (#BP) occurred inside an RTM region while advanced debugging of RTM transactional regions was enabled. Note that this is the opposite of DR6.RTM, which "indicates (when clear) that a debug exception (#DB) or breakpoint exception (#BP) occurred inside an RTM region while advanced debugging of RTM transactional regions was enabled." There is still an issue with stale DR6 bits potentially being misreported for the current debug exception. DR6 should not have been modified before vectoring the #DB exception, and the "new DR6 bits" should be available somewhere, but it was and they aren't. Fixes: b96fb439774e1 ("KVM: nVMX: fixes to nested virt interrupt injection") Signed-off-by: Jim Mattson Reviewed-by: Sean Christopherson Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 09b2e3e2cf1b..1c09a0d1771f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -177,6 +177,7 @@ enum { #define DR6_BD (1 << 13) #define DR6_BS (1 << 14) +#define DR6_BT (1 << 15) #define DR6_RTM (1 << 16) #define DR6_FIXED_1 0xfffe0ff0 #define DR6_INIT 0xffff0ff0 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e665aa7167cf..a933ce5ec1ff 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3294,10 +3294,13 @@ static int nested_vmx_check_exception(struct kvm_vcpu *vcpu, unsigned long *exit } } else { if (vmcs12->exception_bitmap & (1u << nr)) { - if (nr == DB_VECTOR) + if (nr == DB_VECTOR) { *exit_qual = vcpu->arch.dr6; - else + *exit_qual &= ~(DR6_FIXED_1 | DR6_BT); + *exit_qual ^= DR6_RTM; + } else { *exit_qual = 0; + } return 1; } } -- 2.17.1