Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The `vmx_handle_exit()` function silently drops negative error codes (fatal errors) when `bus_lock_detected` is true.
--
--- Patch [3]: [PATCH v2 3/3] KVM: TDX: Enable Bus Lock VM exit ---
commit 573aa824013208febeaa70c68e452e3344dd518c
Author: Xiaoyao Li <[email protected]>
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 and adding the
exit handler. It also handles clearing the bus_lock_detected bit to avoid
issues during the wait_for_sept_zap case.
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 2c8844acbd43e..ee3c7a32361a4 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
[ ... ]
> @@ -2150,6 +2154,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;
> + }
[Severity: High]
This is a pre-existing issue, but since you fixed the negative return value
handling here for tdx_handle_exit() in v2, should a similar fix be applied
to the pre-existing vmx_handle_exit() in arch/x86/kvm/vmx/vmx.c?
Looking at vmx_handle_exit(), if __vmx_handle_exit() returns a negative
error code (e.g. -ENOMEM) and bus_lock_detected is true, it unconditionally
overrides the negative return value to 0:
if (vmx_get_exit_reason(vcpu).bus_lock_detected) {
if (ret > 0)
vcpu->run->exit_reason = KVM_EXIT_X86_BUS_LOCK;
vcpu->run->flags |= KVM_RUN_X86_BUS_LOCK;
return 0;
}
Because ret > 0 is false, it skips setting vcpu->run->exit_reason but still
returns 0 (success) to userspace.
Does this result in userspace receiving a successful return code but with a
stale or uninitialized exit_reason, likely leading to a VMM crash or
unexpected termination if a guest triggers a bus lock exit while KVM
hits an internal error?
> +
> + vcpu->run->flags |= KVM_RUN_X86_BUS_LOCK;
> + }
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.