mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Hao Xiang <hao.xiang@linux.alibaba.com>, kvm@vger.kernel.org
Cc: shannon.zhao@linux.alibaba.com, pbonzini@redhat.com,
	linux-kernel@vger.kernel.org, seanjc@google.com
Subject: Re: [PATCH v2] KVM: VMX: Remove redundant handling of bus lock vmexit
Date: Fri, 15 Oct 2021 16:43:40 +0800	[thread overview]
Message-ID: <11416416-8fc8-f4db-71d6-5205f3b7515e@intel.com> (raw)
In-Reply-To: <8cda9b23-9985-5b59-5d9b-eee4f798fb38@linux.alibaba.com>

On 10/15/2021 3:28 PM, Hao Xiang wrote:
> 
> 
> On 2021/10/15 14:46, Xiaoyao Li wrote:
>> On 10/15/2021 11:57 AM, Hao Xiang wrote:
>>> Hardware may or may not set exit_reason.bus_lock_detected on BUS_LOCK
>>> VM-Exits. Dealing with KVM_RUN_X86_BUS_LOCK in handle_bus_lock_vmexit
>>> could be redundant when exit_reason.basic is EXIT_REASON_BUS_LOCK.
>>>
>>> We can remove redundant handling of bus lock vmexit. Force Setting
>>> exit_reason.bus_lock_detected in handle_bus_lock_vmexit(), and deal with
>>> KVM_RUN_X86_BUS_LOCK only in vmx_handle_exit().
>>>
>>> Suggested-by: Sean Christopherson <seanjc@google.com>
>>> Signed-off-by: Hao Xiang <hao.xiang@linux.alibaba.com>
>>> ---
>>> v1 -> v2: a little modifications of comments
>>>
>>>   arch/x86/kvm/vmx/vmx.c | 15 +++++++++------
>>>   1 file changed, 9 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>>> index 116b089..22be02e 100644
>>> --- a/arch/x86/kvm/vmx/vmx.c
>>> +++ b/arch/x86/kvm/vmx/vmx.c
>>> @@ -5562,9 +5562,13 @@ static int handle_encls(struct kvm_vcpu *vcpu)
>>>   static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)
>>>   {
>>> -    vcpu->run->exit_reason = KVM_EXIT_X86_BUS_LOCK;
>>> -    vcpu->run->flags |= KVM_RUN_X86_BUS_LOCK;
>>> -    return 0;
>>> +    /*
>>> +     * Hardware may or may not set the BUS_LOCK_DETECTED flag on 
>>> BUS_LOCK
>>> +     * VM-Exits, force setting the flag 
>>
>>>          so that the logic in vmx_handle_exit()
>>> +     * doesn't have to handle the flag and the basic exit reason.
>>
>> The code itself looks good.
>>
>> But the comment is partly incorrect. Now we rely only on the 
>> bus_lock_detected flag so vmx_handle_exit() must check the flag.
>> Thank you for you advice. Is the following comment ok?
> /*
>   * Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK
>   * VM-Exits. Forcely set the flag here, then check the flag in
>   * vmx_handle_exit() and handle the bus lock vmexit if the flag is
>   * set.
>   */

(I'm not sure if forcely is a valid word)

how about

/*
  * Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK
  * VM Exit. Unconditionally set the flag here and leave the handling to
  * vmx_handle_exit().
  */

>>> +     */
>>> +    to_vmx(vcpu)->exit_reason.bus_lock_detected = true;
>>> +    return 1;
>>>   }
>>>   /*
>>> @@ -6051,9 +6055,8 @@ static int vmx_handle_exit(struct kvm_vcpu 
>>> *vcpu, fastpath_t exit_fastpath)
>>>       int ret = __vmx_handle_exit(vcpu, exit_fastpath);
>>>       /*
>>> -     * Even when current exit reason is handled by KVM internally, we
>>> -     * still need to exit to user space when bus lock detected to 
>>> inform
>>> -     * that there is a bus lock in guest.
>>> +     * Exit to user space when bus lock detected to inform that 
>>> there is
>>> +     * a bus lock in guest.
>>>        */
>>>       if (to_vmx(vcpu)->exit_reason.bus_lock_detected) {
>>>           if (ret > 0)
>>>


      reply	other threads:[~2021-10-15  8:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  3:57 Hao Xiang
2021-10-15  6:46 ` Xiaoyao Li
2021-10-15  7:28   ` Hao Xiang
2021-10-15  8:43     ` Xiaoyao Li [this message]

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=11416416-8fc8-f4db-71d6-5205f3b7515e@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=hao.xiang@linux.alibaba.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=shannon.zhao@linux.alibaba.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 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®