Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 2/3] KVM: x86: Reject enabling KVM_CAP_X86_BUS_LOCK_EXIT when !kvm_caps.has_bus_lock_exit
Date: Fri, 7 Aug 2026 09:27:04 +0800	[thread overview]
Message-ID: <f9847f77-908b-48e9-b3a4-af487bbed97f@intel.com> (raw)
In-Reply-To: <20260806113501.3F28C1F000E9@smtp.kernel.org>

On 8/6/2026 7:35 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> 
> Pre-existing issues:
> - [High] Modifying the VM-wide state `kvm->arch.bus_lock_detection_enabled` lacks protection from `kvm->lock` and does not verify that no vCPUs have been created yet.
> --
> 
> --- Patch [2]: [PATCH 2/3] KVM: x86: Reject enabling KVM_CAP_X86_BUS_LOCK_EXIT when !kvm_caps.has_bus_lock_exit ---
> commit e0edfcdc943c7835281cad8477ff3399dfe81a05
> Author: Xiaoyao Li <xiaoyao.li@intel.com>
> 
> KVM: x86: Reject enabling KVM_CAP_X86_BUS_LOCK_EXIT when !kvm_caps.has_bus_lock_exit
> 
> This commit returns -EINVAL to reject enabling KVM_CAP_X86_BUS_LOCK_EXIT
> or KVM_BUS_LOCK_DETECTION_OFF from userspace when kvm_caps.has_bus_lock_exit
> is false. It aims to keep the API behavior consistent when KVM does not
> support bus lock exit.
> 
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index afcac1042947a..91895a3d6f857 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -6835,8 +6835,10 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
>>   		    (cap->args[0] & KVM_BUS_LOCK_DETECTION_EXIT))
>>   			break;
>>   
>> -		if (kvm_caps.has_bus_lock_exit &&
>> -		    cap->args[0] & KVM_BUS_LOCK_DETECTION_EXIT)
>> +		if (!kvm_caps.has_bus_lock_exit)
>> +			break;
>> +
>> +		if (cap->args[0] & KVM_BUS_LOCK_DETECTION_EXIT)
>>   			kvm->arch.bus_lock_detection_enabled = true;
> 
> [Severity: High]
> This is a pre-existing issue, but does setting the VM-wide flag
> bus_lock_detection_enabled here in kvm_vm_ioctl_enable_cap() require
> kvm->lock protection and a check for !kvm->created_vcpus?
> 
> If userspace calls KVM_ENABLE_CAP for KVM_CAP_X86_BUS_LOCK_EXIT concurrently
> with or after KVM_CREATE_VCPU, existing vCPUs might miss the update. This
> could lead to an inconsistent state where some vCPUs mitigate bus lock DoS
> and others do not, leaving the host vulnerable.

This is addressed by the next patch.

>>   		r = 0;
>>   		break;
> 


  reply	other threads:[~2026-08-07  1:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 11:19 [PATCH 0/3] KVM: x86: BUS_LOCK_EXIT fixes Xiaoyao Li
2026-08-06 11:19 ` [PATCH 1/3] KVM: VMX: Preserve negative return value in vmx_handle_exit() with bus lock detected Xiaoyao Li
2026-08-06 11:19 ` [PATCH 2/3] KVM: x86: Reject enabling KVM_CAP_X86_BUS_LOCK_EXIT when !kvm_caps.has_bus_lock_exit Xiaoyao Li
2026-08-06 11:35   ` sashiko-bot
2026-08-07  1:27     ` Xiaoyao Li [this message]
2026-08-06 14:31   ` Sean Christopherson
2026-08-06 11:19 ` [PATCH 3/3] KVM: x86: Only allow enabling KVM_BUS_LOCK_DETECTION_EXIT before creating any vCPU Xiaoyao Li

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=f9847f77-908b-48e9-b3a4-af487bbed97f@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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