x86/split_lock: Fix and enhancement for TDX guest
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 9 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | x86/split_lock: Don't try to handle user split lock in TDX guestarch/ | +16 | 9 replies | |
| 2/2 | x86/split_lock: Describe #AC handling in TDX guest kernel logarch/ | +3 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] x86/split_lock: Fix and enhancement for TDX guest
Running a split lock test[1] inside a TDX guest under KVM triggers the warning below. The test hangs but can be terminated.
x86/split lock detection: #AC: split_lock/1176 took a split_lock trap at address: 0x5630b30921f9
unchecked MSR access error: WRMSR to 0x33 (tried to write 0x0000000000000000) at rIP: 0xffffffff812a061f (native_write_msr+0xf/0x30)
Call Trace: handle_user_split_lock exc_alignment_check asm_exc_alignment_check
It turns out that split lock detection is enabled (by the host) when the TDX vCPU is running, and #AC is not intercepted but delivered directly to the TDX guest. The default "warning" mode of split lock #AC handler in the guest tries to handle the split lock by temporarily disabling detection. However, the MSR that disables detection is not accessible to a guest.
Patch 1 forces the TDX guest to always treat the split lock #AC as the "fatal" mode. This prevents the TDX guest from attempting invalid MSR writes.
Patch 2 enhances the sld_state_show() to indicate that the TDX guest can receive #AC on split locks depending on the host's split lock detection configuration.
Note that all the split lock issues on TDX guests are due to the non-architectural behavior of TDX: a TDX guest can receive #AC even though the split lock detection feature is not available and the relevant MSR is not accessible.
One option is to make the behavior architectural for TDX guests by not delivering the (unexpected) #AC to the TDX guest and letting the host handle it instead. This is exactly how KVM handles split lock #AC for normal VMs. This option also has the advantage that the TDX guest can survive from split locks when the host mode is not fatal.
However, this option cannot replace current patches because it changes the behavior of current TDX and would need to be opted-in by the host VMM for compatibility. More importantly, it would be a new feature available only in newer TDX modules, which means all existing TDX modules cannot benefit from it.
We list the option here as an open to solicit feedback and determine whether to pursue adding such feature to TDX module.
[1] https://github.com/xiaoyaoli-intel/splitlock/blob/main/splitlock.c
Xiaoyao Li (2):
x86/split_lock: Don't try to handle user split lock in TDX guest x86/split_lock: Describe #AC handling in TDX guest kernel log
arch/x86/kernel/cpu/bus_lock.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
base-commit: ac3fd01e4c1efce8f2c054cdeb2ddd2fc0fb150d
Signature · 1 line
2.43.0