Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1185473imm; Fri, 22 Jun 2018 11:49:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKFPB/1dIn7jEpCsRJuWK31fOiP86eMGENN4hlJ1yhYZYOaTbKfmsBOwGZS7ZSvxbqMu1Vj X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr1670225plo.258.1529693343325; Fri, 22 Jun 2018 11:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529693343; cv=none; d=google.com; s=arc-20160816; b=JYqChfs9tyUZgpETkv4+wppDvYobdYb20xp+tISPtrUSE8ibG1FiJUlV/cewyXU+S4 8XIWDkXiXdqQJBoW/TMI9kaqtEpeK1TFRPzNT4eQTMaiztle0oINnZvJrRCq/sp6XDTB QL5QQFAt8+2q+4y27+DnRkpvRvBP4mM8brJXPHEVjJE0x97M5jNbdQNx+1ml0KEwyeIn 8thYu4MsPvSnbQm2mB4IESM4xXZ2J7fswyKcRFm5OzrZs87AurHyl8jDSz084/SHlcmZ OeVBwTic9va2yLoWHIG29YyMTCdp8USVbiLqpXArZ4vi/QCQ3kYXvGCOJADiJxljRB+V VysA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=/xQMvOX+wn+upD4gOLoQQyz13avEDlwCp+uAwCYbbQQ=; b=jpeRtBruU9kQcW6aqmcYXHPMCJwGfMOZIkLMAez9Kxr7NubCPZH5y1qsflSUmSOp+u KY/+gCroQycinUHuYQWtMcT/i5tD6t+0k9Y+urU88GCiPlERjZsIxv3e9bAkn5Ohykog EoukhpUDM+z0JybX3v1NvkmXgihThxC4I6i7r3gjJEvwTAazusB97DneXSw3fERqXKPy uikor7hX7QjlGssBYyXD0Il8dMPnZBTyXqEFjGbV9dUaKYRkYfA65IHA9mT0nrF1Sv56 4bS/k4K7C1Vi55kmlGbV3AMbltHBI8ki+IUWVVRrhaKT7hUt54P2q0Q/w8meRLKGfavo 7X7A== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11-v6si7870934pln.442.2018.06.22.11.48.48; Fri, 22 Jun 2018 11:49:03 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934410AbeFVSrz (ORCPT + 99 others); Fri, 22 Jun 2018 14:47:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33916 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933878AbeFVSrx (ORCPT ); Fri, 22 Jun 2018 14:47:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6B6B7B4A7; Fri, 22 Jun 2018 18:47:52 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 2A24C2026D6C; Fri, 22 Jun 2018 18:47:49 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Fri, 22 Jun 2018 20:47:48 +0200 Date: Fri, 22 Jun 2018 20:47:48 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Borislav Petkov Cc: KVM , Joerg Roedel , Tom Lendacky , Tony Luck , Yazen Ghannam , LKML Subject: Re: [PATCH 3/3] x86/kvm: Handle all MCA banks Message-ID: <20180622184748.GB2377@flask> References: <20180622095101.32587-1-bp@alien8.de> <20180622095101.32587-4-bp@alien8.de> <20180622181603.GB5549@flask> <20180622182419.GE1882@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180622182419.GE1882@zn.tnic> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 22 Jun 2018 18:47:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 22 Jun 2018 18:47:52 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-06-22 20:24+0200, Borislav Petkov: > On Fri, Jun 22, 2018 at 08:16:04PM +0200, Radim Krčmář wrote: > > 2018-06-22 11:51+0200, Borislav Petkov: > > > From: Borislav Petkov > > > > > > Extend the range of MCA banks which get passed to set/get_msr_mce() to > > > include all the MSRs of the last bank too. > > > > > > Signed-off-by: Borislav Petkov > > > --- > > > arch/x86/kvm/x86.c | 5 +++-- > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > > index 80452b0f0e8c..a7d344823356 100644 > > > --- a/arch/x86/kvm/x86.c > > > +++ b/arch/x86/kvm/x86.c > > > @@ -2466,7 +2466,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > > > > > > case MSR_IA32_MCG_CTL: > > > case MSR_IA32_MCG_STATUS: > > > - case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_CTL(KVM_MAX_MCE_BANKS) - 1: > > > + case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_MISC(KVM_MAX_MCE_BANKS) - 1: > > > > It was correct before. We have 32 banks (KVM_MAX_MCE_BANKS), so the > > last useable has index 31 and the "- 1" is going to roll over from first > > MSR of bank 32 to the last MSR of the last bank. > > > > Another way of writing it would be: > > > > case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_MISC(KVM_MAX_MCE_BANKS - 1): > > Huh? > > This is what I did: > > + case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_MISC(KVM_MAX_MCE_BANKS) - 1: > > It needs to be MISC because it is the last MSR in the MCA bank and thus > the highest. The last MSR is the original "MSR_IA32_MCx_CTL(KVM_MAX_MCE_BANKS) - 1". "MSR_IA32_MCx_MISC(KVM_MAX_MCE_BANKS) - 1" also covers MSR_IA32_MC32_CTL, MSR_IA32_MC32_STATUS, and MSR_IA32_MC32_ADDR but the maximal valid MSR is MSR_IA32_MC31_MISC.