Re: [PATCH v4 8/9] KVM: TDX: Enable Bus Lock VM exit

From: Nikolay Borisov

Date: Wed Aug 26 2026 - 06:43:00 EST




On 8/19/26 12:49, Xiaoyao Li wrote:
Enable Bus Lock VM exit functionality for TDX guests.

Bus Lock VM exit is an existing feature supported by KVM. Userspace can
enable Bus Lock VM exit through KVM_BUS_LOCK_DETECTION_EXIT when it's
reported as supported. However, KVM reports the support of this CAP
just based on the hardware capability but doesn't differentiate between
VMX and TDX. This leads to the issue that userspace can enable this cap
for TDX guests without getting an error, but the feature is not actually
enabled because KVM doesn't call the TDX module API to program the
relevant TD VMCS fields.

Enable Bus Lock VM exit for TDX guests by programming the
BUS_LOCK_DETECTION control in the TD VMCS and by adding the exit handler.

Note, there is no enumeration bit for this feature by TDX module because
all TDX modules support it and allow to set the TD VMCS as long as the
hardware supports the feature.

Fixes: 161d34609f9b ("KVM: TDX: Make TDX VM type supported")
Cc: stable@xxxxxxxxxxxxxxx
Originally-by: Chenyi Qiang <chenyi.qiang@xxxxxxxxx>
Signed-off-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>
---
Changes in 4:
- The code to make handle_bus_lock_vmexit() a shared helper is split
as a separate patch.
- The handling for wait_for_sept_zap is no longer needed since a general
handling for it is added as a separate patch.

Changes in v3:
- Refine the changelog. (Rick)

Changes in v2:
- Don't overwrite the negative return value to 0. (Sashiko)
- Clear the bus_lock_detected bit when it returns early for
wait_for_sept_zap case.
- Add a note to clarify the feature is always supported by the TDX
module, to make Sashiko happy.

Reviewed-by: Nikolay Borisov <nik.borisov@xxxxxxxx>