Skip to content

Commit 1f62531

Browse files
committed
KVM: TDX: Skip updating CPU dirty logging request for TDs
Wrap vmx_update_cpu_dirty_logging so as to ignore requests to update CPU dirty logging for TDs, as basic TDX does not support the PML feature. Invoking vmx_update_cpu_dirty_logging() for TDs would cause an incorrect access to a kvm_vmx struct for a TDX VM, so block that before it happens. Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent fbb4ada commit 1f62531

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

arch/x86/kvm/vmx/main.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ static void vt_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
129129
vmx_vcpu_load(vcpu, cpu);
130130
}
131131

132+
static void vt_update_cpu_dirty_logging(struct kvm_vcpu *vcpu)
133+
{
134+
/*
135+
* Basic TDX does not support feature PML. KVM does not enable PML in
136+
* TD's VMCS, nor does it allocate or flush PML buffer for TDX.
137+
*/
138+
if (WARN_ON_ONCE(is_td_vcpu(vcpu)))
139+
return;
140+
141+
vmx_update_cpu_dirty_logging(vcpu);
142+
}
143+
132144
static void vt_flush_tlb_all(struct kvm_vcpu *vcpu)
133145
{
134146
if (is_td_vcpu(vcpu)) {
@@ -322,7 +334,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
322334
.check_intercept = vmx_check_intercept,
323335
.handle_exit_irqoff = vmx_handle_exit_irqoff,
324336

325-
.update_cpu_dirty_logging = vmx_update_cpu_dirty_logging,
337+
.update_cpu_dirty_logging = vt_update_cpu_dirty_logging,
326338

327339
.nested_ops = &vmx_nested_ops,
328340

0 commit comments

Comments
 (0)