KVM: interrupt kvm_gmem_populate() on signals
Subsystems (2)
Paolo Bonzini
maintainerPATCH 1/1 KVM: interrupt kvm_gmem_populate() on signals
kvm_gmem_populate() is a potentially lengthy operation that can involve multiple calls to the firmware. Interrupt it if a signal arrives.
Fixes 1f6c06b177513 ("KVM: guest_memfd: Add interface for populating gmem pages with user data")
Cc Isaku Yamahata <[email protected]>
Cc Michael Roth <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>
--- virt/kvm/guest_memfd.c | 5 +++++ 1 file changed, 5 insertions(+)
virt/kvm/guest_memfd.c +5 -0
@@ -629,6 +629,11 @@ long kvm_gmem_populate(struct kvm *kvm, gfn_t start_gfn, void __user *src, longgfn_t gfn = start_gfn + i;kvm_pfn_t pfn; +if (signal_pending (current)) { + ret = -EINTR ; +break ; + } + ret =__kvm_gmem_get_pfn (file, slot, gfn, &pfn, &max_order, false);if (ret)break ;
Signature · 1 line
2.43.0
Quoted 2 lines · Paolo Bonzini
kvm_gmem_populate()is a potentially lengthy operation that can involve multiple calls to the firmware. Interrupt it if a signal arrives.
What about cond_resched() in the loop? kvm_gmem_allocate() has both.
The change itself looks good for TDX because KVM_TDX_INIT_MEMREGION checks the signal. I can drop the duplicated check. Similar to cond_resched().
Signature · 1 line
Isaku Yamahata <[email protected]>