Skip to content

Commit 4730808

Browse files
committed
KVM: TDX: Skip updating CPU dirty logging request for TDs
JIRA: https://issues.redhat.com/browse/RHEL-15711 Upstream status: https://git.kernel.org/pub/scm/virt/kvm/kvm.git 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> (cherry picked from commit 1f62531) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> RHEL: context
1 parent 817168d commit 4730808

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)) {
@@ -321,7 +333,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
321333

322334
.sched_in = vmx_sched_in,
323335

324-
.update_cpu_dirty_logging = vmx_update_cpu_dirty_logging,
336+
.update_cpu_dirty_logging = vt_update_cpu_dirty_logging,
325337

326338
.nested_ops = &vmx_nested_ops,
327339

0 commit comments

Comments
 (0)