Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3835183pxb; Tue, 10 Nov 2020 00:54:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRu3dfXQ4H2UypiDfUojFNO4PY8/AwKnEsPHo0rPgeMq+fhrfHB5t18vh/v+FcJQt5VXhX X-Received: by 2002:a05:6402:3131:: with SMTP id dd17mr19839302edb.58.1604998468027; Tue, 10 Nov 2020 00:54:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604998468; cv=none; d=google.com; s=arc-20160816; b=U0/qaHO+k092d2lPI0LHy8UD/vV6I/8uU589bZ5vsYfVACS0OmBMcKog3J89z+TFwL JMj7j+aG2CzIPrrojXcpCoODQ551q2zqxxCkYDDUpk00RuUEBZ8x5d/d4Vs6plnIg++D cn8GqpZDaLdIRPrIIhdXY/f656jEaP/i9wBSBUgox3Gm/6ZiyPnxaycmXWeAbpX4VqEd 4IruWXUg2d7PqYv4oTWpErFkPFjamJVrO3CG0b6rp3AehJSCSmj54xDNQGzP4EHMmKqg 9ff7aAj4kvCuRCozuH8AkcostFfhZ6MlpUOh8GyrrhcCXOVVTgc0wQ8xUfFR4LBBXheD YcEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=CUPbC36bNhgEeHhTK8bYaDtKD7TRWDMLJYdSByDYhoQ=; b=H9aNJb2CCeTbypYQq9umWYvFX84KgWLzq3gWHvnn1t4goCeLlVNXqgnYPvIM0R9IVL nvEQIGJWocBws+E0FabYTE+pKs2K5eHSlhXMHC62hsRG/H4O1stpGe6JNKCh3j1ovb+B AKqaAC/GqWqjM2/R9mCp55AS12JHKJ+lJqxQjm3ss3/8Cyv+CakFagsyObmMirOoY+a4 JDSj1GouyUDgEUpzT/tw1HP+/78nfrrY+JE7/aw6PnLTBPEUEBRCb9tk83Tg3vAiSBcB TwBQ7g9Dx5yN5e1ThoG2Dtmh3GNEapWfSJFXzUA9hvlaLKs4f51Eb0PncAas+Qm2WvAJ hxhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fFjVyqMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r24si9078956edq.456.2020.11.10.00.54.04; Tue, 10 Nov 2020 00:54:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fFjVyqMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731738AbgKJIuv (ORCPT + 99 others); Tue, 10 Nov 2020 03:50:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30707 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbgKJIut (ORCPT ); Tue, 10 Nov 2020 03:50:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604998248; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CUPbC36bNhgEeHhTK8bYaDtKD7TRWDMLJYdSByDYhoQ=; b=fFjVyqMOC6pNwjvvDVFsRiRpDZ9G+6NZnT01Ng9kqppSgBA6zBPu8v/gFENhvVltQgD8/K kRj7dtlndkHAJeQHpfts/pnBlmz/tAlUh1D4L0OnAS23xC7Xgb1ajtx5e2g2wlU/XPzjG1 Q1NUT/5xaZhrt2XtFimlYkfFOVabIok= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-SqNKZq_AOjqiZZrb0HlRwg-1; Tue, 10 Nov 2020 03:50:46 -0500 X-MC-Unique: SqNKZq_AOjqiZZrb0HlRwg-1 Received: by mail-ed1-f70.google.com with SMTP id b13so3900477edy.8 for ; Tue, 10 Nov 2020 00:50:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CUPbC36bNhgEeHhTK8bYaDtKD7TRWDMLJYdSByDYhoQ=; b=f7CoWz+UvaiV62okzHJbv7AiQi9DOJJ+5tEegAUY/tcLlT4MOpROjrXldrSf4eWFEo YVSF6yGfEKE1OOgFGRBWOgx+NKNvUR2jq/lPDG1GdcaidkZaDkn2CPbDhjcLPZkaQ8Fi YaRPnX8XTiXx2eiXtpMt6Koe80ql2/TqpmdR7FdiBhZ2O/hVuyR3uZSWTpaiw+j7lw+e C5DCrNcA43rxV7rplMGRZRewR7PlAJpJkQzsL/NX84o3CfEIMpSyaaAbPrw4hOnMB/4H Tj/R47z8chW5VFOD5euGu7EPLX7DKXOzRPrxz62ZDZThQYU9Zcjr3kQsHuMPgmtB0p9V pHpA== X-Gm-Message-State: AOAM530ttBkOUEgzBaKx9VKiALM2kiHksYF9NElbrDHR6cOg1mCbseA2 /wwT6kt6Nd6Vrh/11KKVJUhWfsyG8BpLJiKvQs+vLK6xdkptRrbc0yTnJEIqvKF86Z0Cslwli5H F6XLM5S3Zm0352BsKGzLAkSqo X-Received: by 2002:aa7:cd56:: with SMTP id v22mr20488896edw.245.1604998244811; Tue, 10 Nov 2020 00:50:44 -0800 (PST) X-Received: by 2002:aa7:cd56:: with SMTP id v22mr20488883edw.245.1604998244638; Tue, 10 Nov 2020 00:50:44 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id l20sm10105014eja.40.2020.11.10.00.50.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Nov 2020 00:50:43 -0800 (PST) To: Borislav Petkov , "Luck, Tony" Cc: Jim Mattson , Qian Cai , "linux-kernel@vger.kernel.org" , "linux-tip-commits@vger.kernel.org" , x86 , "kvm@vger.kernel.org" References: <20201030190807.GA13884@agluck-desk2.amr.corp.intel.com> <160431588828.397.16468104725047768957.tip-bot2@tip-bot2> <3f863634cd75824907e8ccf8164548c2ef036f20.camel@redhat.com> <20201109232402.GA25492@agluck-desk2.amr.corp.intel.com> <20201110063151.GB7290@nazgul.tnic> From: Paolo Bonzini Subject: Re: [PATCH] x86/mce: Check for hypervisor before enabling additional error logging Message-ID: <094c2395-b1b3-d908-657c-9bd4144e40ac@redhat.com> Date: Tue, 10 Nov 2020 09:50:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201110063151.GB7290@nazgul.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/11/20 07:31, Borislav Petkov wrote: >> >> + if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) >> + return; >> + > Frankly, I'm tired of wagging the dog because the tail can't. If > qemu/kvm can't emulate a CPU model fully then it should ignore those > unknown MSR accesses by default, i.e., that "ignore_msrs" functionality > should be on by default I'd say... > > We certainly can't be sprinkling this check everytime the kernel tries > to do something as basic as read an MSR. You don't have to, also because it's wrong. Fortunately it's much simpler than that: 1) ignore_msrs _cannot_ be on by default. You cannot know in advance that for all non-architectural MSRs it's okay for them to read as zero and eat writes. For some non-architectural MSR which never reads as zero on real hardware, who knows that there isn't some code using the contents of the MSR as a divisor, and causing a division by zero exception with ignore_msrs=1? 2) it's not just KVM. _Any_ hypervisor is bound to have this issue for some non-architectural MSRs. KVM just gets the flak because Linux CI environments (for obvious reasons) use it more than they use Hyper-V or ESXi or VirtualBox. 3) because of (1) and (2), the solution is very simple. If the MSR is architectural, its absence is a KVM bug and we'll fix it in all stable versions. If the MSR is not architectural (and 17Fh isn't; not only it's not mentioned in the SDM, even Google is failing me), never ever assume that the CPUID family/model/stepping implies a given MSR is there, and just use rdmsr_safe/wrmsr_safe. So, for this patch, Nacked-by: Paolo Bonzini Paolo