From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
hpa@zytor.com, Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <sean.j.christopherson@intel.com>
Cc: x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Arvind Sankar <nivedita@alum.mit.edu>,
Fenghua Yu <fenghua.yu@intel.com>,
Tony Luck <tony.luck@intel.com>
Subject: Re: [PATCH v6 8/8] kvm: vmx: virtualize split lock detection
Date: Thu, 26 Mar 2020 20:31:02 +0800 [thread overview]
Message-ID: <24bf6735-ce80-0c4a-ed67-946aefc7a5f9@intel.com> (raw)
In-Reply-To: <87ftdvxtjh.fsf@nanos.tec.linutronix.de>
On 3/26/2020 7:08 PM, Thomas Gleixner wrote:
> Xiaoyao Li <xiaoyao.li@intel.com> writes:
>> On 3/25/2020 9:41 AM, Thomas Gleixner wrote:
>>> If you really want to address that scenario, then why are you needing
>>> any of those completely backwards interfaces at all?
>>>
>>> Just because your KVM exception trap uses the host handling function
>>> which sets TIF_SLD?
>>>
>> Yes. just because KVM use the host handling function.
>
>> If you disallow me to touch codes out of kvm. It can be achieved with
>
> Who said you cannot touch code outside of KVM?
>
>> Obviously re-use TIF_SLD flag to automatically switch MSR_TEST_CTRL.SLD
>> bit when switch to/from vcpu thread is better.
>
> What's better about that?
>
> TIF_SLD has very well defined semantics. It's used to denote that the
> SLD bit needs to be cleared for the task when its scheduled in.
>
> So now you overload it by clearing it magically and claim that this is
> better.
>
> vCPU-thread
>
> user space (qemu)
> triggers #AC
> -> exception
> set TIF_SLD
>
> iotctl()
> vcpu_run()
> -> clear TIF_SLD
>
> It's not better, it's simply wrong and inconsistent.
>
>> And to virtualize SLD feature as full as possible for guest, we have to
>> implement the backwards interface. If you really don't want that
>> interface, we have to write code directly in kvm to modify TIF_SLD flag
>> and MSR_TEST_CTRL.SLD bit.
>
> Wrong again. KVM has absolutely no business in fiddling with TIF_SLD and
> the function to flip the SLD bit is simply sld_update_msr(bool on) which
> does not need any KVMism at all.
>
> There are two options to handle SLD for KVM:
>
> 1) Follow strictly the host rules
>
> If user space or guest triggered #AC then TIF_SLD is set and that
> task is excluded from ever setting SLD again.
Obviously, it's not about to virtualize SLD for guest. So we don't pick
this one.
> 2) Track KVM guest state separately
>
> vcpu_run()
> if (current_has(TIF_SLD) && guest_sld_on())
> sld_update_msr(true);
> else if (!current_has(TIF_SLD) && !guest_sld_on())
> sld_update_msr(false);
> vmenter()
> ....
> vmexit()
> if (current_has(TIF_SLD) && guest_sld_on())
> sld_update_msr(false);
> else if (!current_has(TIF_SLD) && !guest_sld_on())
> sld_update_msr(true);
>
> If the guest triggers #AC then this solely affects guest state
> and does not fiddle with TIF_SLD.
>
OK. So when host is sld_warn, guest's SLD value can be loaded into
hardware MSR when vmenter.
I'll go with this option.
next prev parent reply other threads:[~2020-03-26 12:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 15:18 [PATCH v6 0/8] x86/split_lock: Fix and virtualization of " Xiaoyao Li
2020-03-24 15:18 ` [PATCH v6 1/8] x86/split_lock: Rework the initialization flow " Xiaoyao Li
2020-03-24 15:18 ` [PATCH v6 2/8] x86/split_lock: Avoid runtime reads of the TEST_CTRL MSR Xiaoyao Li
2020-03-24 15:18 ` [PATCH v6 3/8] x86/split_lock: Export handle_user_split_lock() Xiaoyao Li
2020-03-24 15:18 ` [PATCH v6 4/8] kvm: x86: Emulate split-lock access as a write in emulator Xiaoyao Li
2020-03-25 0:00 ` Thomas Gleixner
2020-03-25 0:31 ` Xiaoyao Li
2020-03-24 15:18 ` [PATCH v6 5/8] kvm: vmx: Extend VMX's #AC interceptor to handle split lock #AC happens in guest Xiaoyao Li
2020-03-24 15:18 ` [PATCH v6 6/8] kvm: x86: Emulate MSR IA32_CORE_CAPABILITIES Xiaoyao Li
2020-03-24 15:18 ` [PATCH v6 7/8] kvm: vmx: Enable MSR_TEST_CTRL for intel guest Xiaoyao Li
2020-03-25 0:07 ` Thomas Gleixner
2020-03-24 15:18 ` [PATCH v6 8/8] kvm: vmx: virtualize split lock detection Xiaoyao Li
2020-03-25 0:40 ` Thomas Gleixner
2020-03-25 1:11 ` Xiaoyao Li
2020-03-25 1:41 ` Thomas Gleixner
2020-03-26 1:38 ` Xiaoyao Li
2020-03-26 11:08 ` Thomas Gleixner
2020-03-26 12:31 ` Xiaoyao Li [this message]
2020-03-26 6:41 ` Xiaoyao Li
2020-03-26 11:10 ` Thomas Gleixner
2020-03-26 12:43 ` Xiaoyao Li
2020-03-26 14:55 ` Thomas Gleixner
2020-03-26 15:09 ` Xiaoyao Li
2020-03-26 18:51 ` Thomas Gleixner
2020-03-24 17:47 ` [PATCH v6 0/8] x86/split_lock: Fix and virtualization of " Sean Christopherson
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=24bf6735-ce80-0c4a-ed67-946aefc7a5f9@intel.com \
--to=xiaoyao.li@intel.com \
--cc=bp@alien8.de \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=nivedita@alum.mit.edu \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=sean.j.christopherson@intel.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®