linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Luck, Tony" <tony.luck@intel.com>,
	Jim Mattson <jmattson@google.com>, Qian Cai <cai@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-tip-commits@vger.kernel.org" 
	<linux-tip-commits@vger.kernel.org>, x86 <x86@kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH] x86/mce: Check for hypervisor before enabling additional error logging
Date: Tue, 10 Nov 2020 10:56:15 +0100	[thread overview]
Message-ID: <20201110095615.GB9450@nazgul.tnic> (raw)
In-Reply-To: <094c2395-b1b3-d908-657c-9bd4144e40ac@redhat.com>

On Tue, Nov 10, 2020 at 09:50:43AM +0100, Paolo Bonzini wrote:
> 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?

So if you're emulating a certain type of hardware - say a certain CPU
model - then what are you saying? That you're emulating it but not
really all of it, just some bits?

Because this is what happens - the kernel checks that it runs on a
certain CPU type and this tells it that those MSRs are there. But then
comes virt and throws all assumptions out.

So if it emulates a CPU model and the kernel tries to access those MSRs,
then the HV should ignore those MSR accesses if it doesn't know about
them. Why should the kernel change everytime some tool or virtualization
has shortcomings?

> 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.

It's not flak - I'm trying to find a solution which is workable for
both. The kernel is not at fault here.

> 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,

It is 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.

Yes, we don't have a choice, as always. ;-\

But maybe we should have a choice and maybe qemu/kvm should have a way
to ignore certain MSRs for certain CPU types, regardless of them being
architectural or not.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2020-11-10  9:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fcb21490-84a1-8b99-b494-3a6ac2a0e16a@skynet.be>
     [not found] ` <20201029100655.GA31903@zn.tnic>
     [not found]   ` <20201029151518.GA23990@agluck-desk2.amr.corp.intel.com>
     [not found]     ` <20201029194118.GC31903@zn.tnic>
     [not found]       ` <87ft5wo8zn.fsf@nanos.tec.linutronix.de>
     [not found]         ` <20201030091056.GA6532@zn.tnic>
     [not found]           ` <20201030190400.GA13797@agluck-desk2.amr.corp.intel.com>
2020-10-30 19:08             ` [PATCH] x86/mce: Enable additional error logging on certain Intel CPUs Luck, Tony
2020-11-02 11:12               ` Borislav Petkov
2020-11-02 11:18               ` [tip: ras/core] " tip-bot2 for Tony Luck
2020-11-09 21:55                 ` Qian Cai
2020-11-09 22:09                   ` Luck, Tony
2020-11-09 22:36                     ` Jim Mattson
2020-11-09 22:57                       ` Luck, Tony
2020-11-09 23:24                         ` [PATCH] x86/mce: Check for hypervisor before enabling additional error logging Luck, Tony
2020-11-10  6:31                           ` Borislav Petkov
2020-11-10  8:50                             ` Paolo Bonzini
2020-11-10  9:56                               ` Borislav Petkov [this message]
2020-11-10 10:40                                 ` Paolo Bonzini
2020-11-10 15:50                                   ` Borislav Petkov
2020-11-10 16:08                                     ` Paolo Bonzini
2020-11-10 17:52                                       ` Luck, Tony
2020-11-10 20:37                                         ` Paolo Bonzini
2020-11-11  0:39                                           ` [PATCH v2] x86/mce: Use "safe" MSR functions when " Luck, Tony
2020-11-16 16:44                                             ` [tip: ras/core] " tip-bot2 for Tony Luck
2020-11-09 23:26                         ` [tip: ras/core] x86/mce: Enable additional error logging on certain Intel CPUs Jim Mattson
2020-11-09 23:36                           ` Luck, Tony
2020-11-10  9:10                             ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201110095615.GB9450@nazgul.tnic \
    --to=bp@alien8.de \
    --cc=cai@redhat.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).