On Tue, Jan 26, 2021, Tom Lendacky wrote: > On 1/26/21 12:54 PM, Peter Gonda wrote: > > sev_pin_memory assumes that callers hold the kvm->lock. This was true for > > all callers except svm_register_enc_region since it does not originate > > from svm_mem_enc_op. Also added lockdep annotation to help prevent > > future regressions. > > I'm not exactly sure what the problem is that your fixing? What is the > symptom that you're seeing? svm_register_enc_region() calls sev_pin_memory() without holding kvm->lock. If userspace does multiple KVM_MEMORY_ENCRYPT_REG_REGION in parallel, it could circumvent the rlimit(RLIMIT_MEMLOCK) check.