Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3735782imu; Mon, 28 Jan 2019 09:52:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN6u3JiFZPPaB4CHRkgTQ1gazJ2+yGUWAK/tjpZTTWw+fiq/BCTStuBLR4Q0VlueHfsZQtiM X-Received: by 2002:a17:902:f20d:: with SMTP id gn13mr21807676plb.11.1548697971499; Mon, 28 Jan 2019 09:52:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548697971; cv=none; d=google.com; s=arc-20160816; b=jDGmdaIkvfeO3CX5nE3wD0zoOXs/canxOux2t7SiiV09p1EVXoj6dK5XEufiYSS5I+ zqxELObYwQM3oPiaDjOpHsTjO2aEIaV+NF9V3UbYA3TP/czDt7L8lj+W1w537yTwsQvJ QoE0NB4D42ouB61KBPtEmqLsHPX641gWSlgAjbRrGae8JUGFkji2yvn8nMer/FzbteUh Ygp8QXHpXpYRCZDAlHtE12m73tixG+o8qUSZktdqNHWMqW6ipFMuXO4JlPHfETG4pqpA pVOurO6R2H5CTjyXH2XVfyW0HHwM9ZtA9py0w0ec4T/Y9L81uzvPbCNiunb6/YGQEPk4 UU2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CFh/ujDWHZz9OPMECaaUL/o5Z/rulgzr5IhbDE9w0ow=; b=RKX/mntTfe6m+RPzrSBXAxnCs3vwQwBFZPSXJhJa+fKTbSyGl0vQg1w1PMB+6pBB7W 9G5dTbdCU+6j0T1lOs5JIRVyJhOxc3/bKNvhQcBu/dinwen93CDUzkHMSZkYdaa1gDgG SQaYpB8flrEVSiSb2Eh3EWNKspFwS/1/u4r39pA3xy0xboBSSv2kUTa5J+yI4QwKg+XC 9mRt4U9MjqRk2YLSUCJthYvJ8rdSrEw/0tdH55hkJ738dLyPAp+p99FS2UFbwHUvWoj8 Zc4rrq6DuxdKsoaQpOTh/AKqisT94HNQo6tXJ7HJFPOLvGLOWWcWEMLpAqpVrMacCF0T Sygg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=leemMJ2A; 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=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si29898439pga.352.2019.01.28.09.52.36; Mon, 28 Jan 2019 09:52:51 -0800 (PST) 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=@yandex-team.ru header.s=default header.b=leemMJ2A; 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=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727573AbfA1Rvm (ORCPT + 99 others); Mon, 28 Jan 2019 12:51:42 -0500 Received: from forwardcorp1o.cmail.yandex.net ([37.9.109.47]:53483 "EHLO forwardcorp1o.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbfA1Rvj (ORCPT ); Mon, 28 Jan 2019 12:51:39 -0500 X-Greylist: delayed 486 seconds by postgrey-1.27 at vger.kernel.org; Mon, 28 Jan 2019 12:51:38 EST Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1o.cmail.yandex.net (Yandex) with ESMTP id CD98021804; Mon, 28 Jan 2019 20:43:30 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id WpIe7eNbvd-hUAm5q0P; Mon, 28 Jan 2019 20:43:30 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1548697410; bh=CFh/ujDWHZz9OPMECaaUL/o5Z/rulgzr5IhbDE9w0ow=; h=From:To:Cc:Subject:Date:Message-Id; b=leemMJ2AqQ/4HO8+zQeBhc/EvSXVOL5jSPGpbYBnMfjBhOosmQeKZGyDWNwTltGu3 oSWAb/Y9vkmZmY2y318KFe9QL4kvLSsb+6zass4bQpeUbyWVN+DmWpuaTw5pfxEIle LsmN5G8MxQLvWhVzWhzbeQ2Qubnv67PySg85UZPY= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:408:250:b6ff:fe97:2682]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id VJGuASzpeM-hU5O80gK; Mon, 28 Jan 2019 20:43:30 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) From: Anton Kuchin To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Evgeny Yakovlev , Anton Kuchin Subject: [PATCH] KVM: Ignore LBR MSRs with no effect Date: Mon, 28 Jan 2019 20:43:22 +0300 Message-Id: <20190128174322.8529-1-antonkuchin@yandex-team.ru> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Win10 attempts to save these registers during KiSaveDebugRegisterState if LBR or BTF bits are set in MSR_IA32_DEBUGCTLMSR. It uses DR7 GE and LE flags for per-thread switching of these these features so zero value that is returned for MSR_IA32_DEBUGCTLMSR has no effect. These registers are used for debugging and shouldn't cause #GP and guest crash so just return zeroes just like we do for common x86 LBR MSRs (DEBUGCTLMSR, LAST[BRANCH|INT][TO|FROM]IP). Signed-off-by: Anton Kuchin --- arch/x86/kvm/vmx/vmx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index f6915f10e584..8bc56cf027ed 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1769,6 +1769,13 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) else msr_info->data = vmx->pt_desc.guest.addr_a[index / 2]; break; + case MSR_LBR_TOS: + case MSR_LBR_NHM_FROM ... MSR_LBR_NHM_FROM + 31: + case MSR_LBR_NHM_TO ... MSR_LBR_NHM_TO + 31: + case MSR_LBR_CORE_FROM ... MSR_LBR_CORE_FROM + 7: + case MSR_LBR_CORE_TO ... MSR_LBR_CORE_TO + 7: + msr_info->data = 0; + break; case MSR_TSC_AUX: if (!msr_info->host_initiated && !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) -- 2.19.1