All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xiaoyao Li" <xiaoyao.li@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 4/4] KVM: TDX: Enable Bus Lock VM exit
Date: Wed, 12 Aug 2026 08:20:28 +0000	[thread overview]
Message-ID: <20260812082029.118791F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812080229.2481439-5-xiaoyao.li@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The preexisting VMX handler vmx_handle_exit() silently drops negative error codes when a bus lock is detected.
--

--- Patch [4]: [PATCH v3 4/4] KVM: TDX: Enable Bus Lock VM exit ---
commit 9ca659baf3acd47c81da72d83946e28ee4de710a
Author: Xiaoyao Li <xiaoyao.li@intel.com>

KVM: TDX: Enable Bus Lock VM exit

This patch enables Bus Lock VM exit functionality for TDX guests by programming
the BUS_LOCK_DETECTION control in the TD VMCS. It also introduces the exit
handler for TDX guests and ensures the bus_lock_detected bit is appropriately
managed without double-counting.

> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 598b85d772e37..e7047657ef780 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
[ ... ]
> @@ -2149,6 +2153,22 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath)
>  	return 0;
>  }
>  
> +int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath)
> +{
> +	int ret = __tdx_handle_exit(vcpu, fastpath);
> +
> +	/* Exit to user space when bus lock was detected */
> +	if (vmx_get_exit_reason(vcpu).bus_lock_detected) {
> +		if (ret > 0) {
> +			vcpu->run->exit_reason = KVM_EXIT_X86_BUS_LOCK;
> +			ret = 0;
> +		}
> +
> +		vcpu->run->flags |= KVM_RUN_X86_BUS_LOCK;
> +	}
> +	return ret;
> +}

[Severity: High]
This isn't a bug introduced by this patch, but while you correctly avoid
overwriting a negative return value here, the pre-existing vmx_handle_exit()
in arch/x86/kvm/vmx/vmx.c appears to still have this flaw.

If __vmx_handle_exit() returns a negative error code (like -EFAULT), and
a bus lock is detected, does vmx_handle_exit() silently drop the negative
error code by unconditionally returning 0?

If this causes ioctl(KVM_RUN) to return 0 instead of -1, could userspace
process stale or uninitialized exit information because
vcpu->run->exit_reason was never updated? 

Should vmx_handle_exit() receive a similar fix?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812080229.2481439-1-xiaoyao.li@intel.com?part=4

  reply	other threads:[~2026-08-12  8:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12  8:02 [PATCH v3 0/4] KVM: TDX: Enable VM-DoS Prevention Features for TDX Xiaoyao Li
2026-08-12  8:02 ` [PATCH v3 1/4] KVM: TDX: Enable Notify VM exit Xiaoyao Li
2026-08-12  8:02 ` [PATCH v3 2/4] KVM: TDX: Set bits 31:16 to 0 for the synthesized Exit Reason Xiaoyao Li
2026-08-12 21:58   ` Edgecombe, Rick P
2026-08-12  8:02 ` [PATCH v3 3/4] KVM: TDX: Don't assume exit_reason[31:16] as all-0 in tdx_to_vmx_exit_reason() Xiaoyao Li
2026-08-12  8:23   ` sashiko-bot
2026-08-12  9:07     ` Xiaoyao Li
2026-08-12 22:55       ` Edgecombe, Rick P
2026-08-13  0:14       ` Sean Christopherson
2026-08-12  8:02 ` [PATCH v3 4/4] KVM: TDX: Enable Bus Lock VM exit Xiaoyao Li
2026-08-12  8:20   ` sashiko-bot [this message]
2026-08-12  9:11     ` Xiaoyao Li
2026-08-13  0:06       ` Sean Christopherson
2026-08-12 22:58   ` Edgecombe, Rick P

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=20260812082029.118791F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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.