All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: x86@kernel.org, "Kenneth R . Crudup" <kenny@panix.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Xiaoyao Li <xiaoyao.li@intel.com>, Nadav Amit <namit@vmware.com>,
	Thomas Hellstrom <thellstrom@vmware.com>,
	Tony Luck <tony.luck@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Jessica Yu <jeyu@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] KVM: VMX: Extend VMX's #AC interceptor to handle split lock #AC in guest
Date: Fri, 03 Apr 2020 00:27:02 +0200	[thread overview]
Message-ID: <87zhbtle15.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20200402205109.GM13879@linux.intel.com>

Sean,

Sean Christopherson <sean.j.christopherson@intel.com> writes:
> On Thu, Apr 02, 2020 at 10:07:07PM +0200, Thomas Gleixner wrote:
>> Sean Christopherson <sean.j.christopherson@intel.com> writes:
>> AFAICT, #AC is not really something which is performance relevant, but I
>> might obviously be uninformed on that.
>> 
>> Assumed it is not, then there is neither a hard requirement nor a real
>> incentive to give up on intercepting #AC even when future CPUs have a
>> fix for the above wreckage.
>
> Agreed that there's no hard requirement, but general speaking, the less KVM
> needs to poke into the guest the better.

Fair enough.

>> > some theoretical unknown #AC source would conditionally result in exits to
>> > userspace depending on whether or not KVM wanted to intercept #AC for
>> > other reasons.
>> 
>> I'd rather like to know when there is an unknown #AC source instead of
>> letting the guest silently swallow it.
>
> Trying to prevent the guest from squashing a spurious fault is a fools
> errand.   For example, with nested virtualization, the correct behavior
> from an architectural perspective is to forward exceptions from L2 (the
> nested VM) to L1 (the direct VM) that L1 wants to intercept.  E.g. if L1
> wants to intercept #AC faults that happen in L2, then KVM reflects all #AC
> faults into L1 as VM-Exits without ever reaching this code.

Which means L1 should have some handling for that case at least those L1
hypervisors which we can fix. If we want to go there.

> Anyways, this particular case isn't a sticking point, i.e. I'd be ok with
> exiting to userspace on a spurious #AC, I just don't see the value in doing
> so.  Returning KVM_EXIT_EXCEPTION doesn't necessarily equate to throwing up
> a red flag, e.g. from a kernel perspective you'd still be relying on the
> userspace VMM to report the error in a sane manner.  I think at one point
> Xiaoyao had a WARN_ON for a spurious #AC, but it was removed because the
> odds of a false positive due to some funky corner case seemed higher than
> detecting a CPU bug.

Agreed. Relying on the user space side to crash and burn the guest is
probably wishful thinking. So the right thing might be to just kill it
right at the spot.

But coming back to the above discussion:

    if (!cpu_has(SLD) || guest_wants_regular_ac()) {
    	kvm_queue_exception_e();
        return 1;
    }

vs.

    if (guest_wants_regular_ac()) {
    	kvm_queue_exception_e();
        return 1;
    }

The only situation where this makes a difference is when the CPU does
not support SLD. If it does the thing became ambiguous today.

With my previous attempt to bring sanity into this by not setting the
feature flag when SLD is disabled at the command line, the check is
consistent.

But the detection of unaware hypervisors with the module scan brings us
into a situation where we have sld_state == sld_off and the feature flag
being set because we can't undo it anymore.

So now you load VMWare which disables SLD, but the feature bit stays and
then when you unload it and load VMX afterwards then you have exactly
the same situation as with the feature check removed. Consistency gone.

So with that we might want to go back to the sld_state check instead of
the cpu feature check, but that does not make it more consistent:

  As I just verified, it's possible to load the vmware module parallel
  to the KVM/VMX one.

So either we deal with it in some way or just decide that SLD and HV
modules which do not have the MOD_INFO(sld_safe) magic cannot be loaded
when SLD is enabled on the host. I'm fine with the latter :)

What a mess.

Thanks,

        tglx


  reply	other threads:[~2020-04-02 22:27 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02 12:32 [patch 0/2] x86: Prevent Split-Lock-Detection wreckage on VMX hypervisors Thomas Gleixner
2020-04-02 12:32 ` [patch 1/2] x86,module: Detect VMX modules and disable Split-Lock-Detect Thomas Gleixner
2020-04-02 15:23   ` [patch v2 " Peter Zijlstra
2020-04-02 16:20     ` Xiaoyao Li
2020-04-02 16:25       ` Peter Zijlstra
2020-04-02 16:39         ` Nadav Amit
2020-04-02 16:41         ` Xiaoyao Li
2020-04-02 17:34           ` Thomas Gleixner
2020-04-02 17:51             ` Sean Christopherson
2020-04-02 18:51               ` Peter Zijlstra
2020-04-02 20:23                 ` Sean Christopherson
2020-04-02 21:04                   ` Thomas Gleixner
2020-04-02 21:16                     ` Sean Christopherson
2020-04-03  8:09     ` David Laight
2020-04-03 14:33       ` Peter Zijlstra
2020-04-02 23:42   ` [patch " Rasmus Villemoes
2020-04-03 14:35     ` Jessica Yu
2020-04-03 15:21       ` Peter Zijlstra
2020-04-03 16:01         ` Sean Christopherson
2020-04-03 16:12           ` Peter Zijlstra
2020-04-03 16:16             ` David Laight
2020-04-03 16:39               ` Peter Zijlstra
2020-04-03 16:25             ` Sean Christopherson
2020-04-03 16:40               ` Peter Zijlstra
2020-04-03 16:48                 ` Nadav Amit
2020-04-03 17:21                   ` Sean Christopherson
2020-04-03 18:53         ` Thomas Gleixner
2020-04-03 20:58           ` Andy Lutomirski
2020-04-03 21:49             ` Thomas Gleixner
2020-04-03 11:29   ` kbuild test robot
2020-04-03 11:29     ` [patch 1/2] x86, module: " kbuild test robot
2020-04-03 14:43   ` [patch 1/2] x86,module: " kbuild test robot
2020-04-03 14:43     ` [patch 1/2] x86, module: " kbuild test robot
2020-04-03 16:36   ` [patch 1/2] x86,module: " Sean Christopherson
2020-04-03 16:41     ` Peter Zijlstra
2020-04-03 18:35       ` Jessica Yu
2020-04-06 12:23   ` Christoph Hellwig
2020-04-06 14:40     ` Peter Zijlstra
2020-04-06 15:18       ` Christoph Hellwig
2020-04-06 15:22         ` Peter Zijlstra
2020-04-06 18:27           ` Steven Rostedt
2020-04-02 12:33 ` [patch 2/2] x86/kvm/vmx: Prevent split lock detection induced #AC wreckage Thomas Gleixner
2020-04-02 15:30   ` Sean Christopherson
2020-04-02 15:44     ` Nadav Amit
2020-04-02 16:04       ` Sean Christopherson
2020-04-02 16:56     ` Thomas Gleixner
2020-04-02 15:55   ` [PATCH 0/3] x86: KVM: VMX: Add basic split-lock #AC handling Sean Christopherson
2020-04-02 15:55     ` [PATCH 1/3] KVM: x86: Emulate split-lock access as a write in emulator Sean Christopherson
2020-04-02 15:55     ` [PATCH 2/3] x86/split_lock: Refactor and export handle_user_split_lock() for KVM Sean Christopherson
2020-04-02 17:01       ` Thomas Gleixner
2020-04-02 17:19         ` Sean Christopherson
2020-04-02 19:06           ` Thomas Gleixner
2020-04-10  4:39             ` Xiaoyao Li
2020-04-10 10:21               ` Paolo Bonzini
2020-04-02 15:55     ` [PATCH 3/3] KVM: VMX: Extend VMX's #AC interceptor to handle split lock #AC in guest Sean Christopherson
2020-04-02 17:19       ` Thomas Gleixner
2020-04-02 17:40         ` Sean Christopherson
2020-04-02 20:07           ` Thomas Gleixner
2020-04-02 20:36             ` Andy Lutomirski
2020-04-02 20:48             ` Peter Zijlstra
2020-04-02 20:51             ` Sean Christopherson
2020-04-02 22:27               ` Thomas Gleixner [this message]
2020-04-02 22:40                 ` Nadav Amit
2020-04-02 23:03                   ` Thomas Gleixner
2020-04-02 23:08                   ` Steven Rostedt
2020-04-02 23:16                     ` Kenneth R. Crudup
2020-04-02 23:18                       ` Jim Mattson
2020-04-03 12:16                         ` Thomas Gleixner
2020-04-10 10:23     ` [PATCH 0/3] x86: KVM: VMX: Add basic split-lock #AC handling Paolo Bonzini
2020-04-10 11:14       ` Thomas Gleixner
2020-04-02 13:43 ` [patch 0/2] x86: Prevent Split-Lock-Detection wreckage on VMX hypervisors Kenneth R. Crudup
2020-04-02 14:32   ` Peter Zijlstra
2020-04-02 14:41     ` Kenneth R. Crudup
2020-04-02 14:46       ` Peter Zijlstra
2020-04-02 14:53         ` Kenneth R. Crudup
2020-04-02 14:37   ` Thomas Gleixner
2020-04-02 14:47     ` Nadav Amit
2020-04-02 15:11       ` Peter Zijlstra

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=87zhbtle15.fsf@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=fenghua.yu@intel.com \
    --cc=jeyu@kernel.org \
    --cc=jmattson@google.com \
    --cc=kenny@panix.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namit@vmware.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sean.j.christopherson@intel.com \
    --cc=thellstrom@vmware.com \
    --cc=tony.luck@intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.