From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Erwan Velu <e.velu@criteo.com>
Cc: Erwan Velu <erwanaliasr1@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm: x86: Print "disabled by bios" only once per host
Date: Wed, 19 Feb 2020 08:18:27 -0800 [thread overview]
Message-ID: <20200219161827.GD15888@linux.intel.com> (raw)
In-Reply-To: <91db305a-1d81-61a6-125b-3094e75b4b3e@criteo.com>
On Wed, Feb 19, 2020 at 12:19:01PM +0100, Erwan Velu wrote:
> On 18/02/2020 19:48, Sean Christopherson wrote:
> [...]
> >Fix userspace to only do the "add" on one CPU.
> >
> >Changing kvm_arch_init() to use pr_err_once() for the disabled_by_bios()
> >case "works", but it's effectively a hack to workaround a flawed userspace.
>
> I'll see with the user space tool to sort this out.
>
> I'm also considering how "wrong" is what they do: udevadm trigger is
> generating 3500 "uevent add" on my system and I only noticed kvm to print
> this noisy message.
>
> So as the print once isn't that "wrong" neither, this simple patch would
> avoid polluting the kernel logs.
>
>
> So my proposal would be
>
> - have this simple patch on the kernel side to avoid having userspace apps
> polluting logs
>
> - contacting the udev people to see the rational & fix it too : I'll do that
>
>
> As you said, once probed, there is no need reprinting the same message again
> as the situation cannot have changed.
For this exact scenario, on Intel/VMX, this is mostly true. But, the MSR
check for AMD/SVM has a disable bit that takes effect irrespective of the
MSR's locked bit, i.e. SVM could theoretically change state without any
super special behavior.
Even on Intel, the state can potentially change, especially on a system
with a misbehaving BIOS. FEATURE_CONTROL is cleared on CPU RESET, e.g. VMX
enabling could change if BIOS "forgets" to reinitialize the MSR upon waking
from S3 (suspend). Things get really weird if we consider the case where
BIOS leaves the MSR unlocked after S3, the user manually writes the MSR,
and then it gets cleared again on a different S3 transition.
SVM is even more sensitive because VM_CR is cleared on INIT, not just RESET.
> As we are on the preliminary return code path (to make a EOPNOTSUPP), I
> would vote for protecting the print against multiple calls/prints.
>
> The kernel patch isn't impacting anyone (in a regular case) and just avoid
> pollution.
>
> Would you agree on that ?
Sadly, no. Don't get me wrong, I completely agree that, ideally, KVM would
not spam the log, even when presented with a misbehaving userspace.
My hesitation about changing the error message to pr_err_once() isn't so
much about right versus wrong as it is about creating misleading and
potentially confusing code in KVM, and setting a precedent that I don't
think we want to carry forward.
E.g. the _once() doesn't hold true if module kvm is unloaded and other
error messages such as basic CPU support would still be unlimited. The
basic CPU support message definitely should *not* be _once() as that would
squash messages when loading the wrong vendor module.
As for setting a precedent, moving the error message to the vendor module
or making kvm a monolithic module would "break" the _once() behavior.
And, the current systemd behavior is actually quite dangerous, e.g. on a
misconfigured system where SVM is enabled on a subset of CPUs, probing KVM
on every CPU essentially guarantees that KVM will be loaded on a broken
system. In that case, I think we actually want the spam. Note, as of
kernel 5.6, this doesn't apply to VMX as kvm_intel will no longer load on a
misconfigured system since FEATURE_CONTROL configuration is incorporated
into the per-CPU checks.
All of that being said, what about converting all of the error messages to
pr_err_ratelimited()? That would take the edge off this particular problem,
wouldn't create incosistencies between error messages, and won't completely
squash error messages in corner case scenarios on misconfigured systems.
next prev parent reply other threads:[~2020-02-19 16:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 14:30 [PATCH] kvm: x86: Print "disabled by bios" only once per host Erwan Velu
2020-02-14 17:05 ` Sean Christopherson
2020-02-18 16:28 ` Erwan Velu
2020-02-18 18:48 ` Sean Christopherson
2020-02-19 11:19 ` Erwan Velu
2020-02-19 11:32 ` Erwan Velu
2020-02-19 17:42 ` Erwan Velu
2020-02-19 16:18 ` Sean Christopherson [this message]
2020-02-19 16:53 ` Erwan Velu
2020-02-19 17:51 ` Paolo Bonzini
2020-02-19 21:52 ` Erwan Velu
2020-02-14 17:43 ` Jim Mattson
2020-02-27 18:00 ` [PATCH v2] kvm: x86: Limit the number of "kvm: disabled by bios" messages Erwan Velu
2020-02-28 10:37 ` 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=20200219161827.GD15888@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=bp@alien8.de \
--cc=e.velu@criteo.com \
--cc=erwanaliasr1@gmail.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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).