Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4999255pxb; Tue, 28 Sep 2021 08:32:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBEDGNAsbB/vK40OUd1Qfa5hsykYSbjGcd6moKdB8rGpcOo1gL0ITch8yom8gnNPGbeW0N X-Received: by 2002:a50:d8c7:: with SMTP id y7mr8349644edj.133.1632843139538; Tue, 28 Sep 2021 08:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632843139; cv=none; d=google.com; s=arc-20160816; b=YFDunGIAkGkzH0zHnc7fdUtCyXUXK3JVOlIv7X16dzNCzT68TSy0a4d8jAEscQ/vH2 cPTEs+m7xZGZeKnu9EoBGJD5jJTrDdjLxgJvvIMorMY0QL11lcP91XBFuXzMhEUHRsIa WdnBVHdrS5+C2HGxrZmCHQIKgtBQzCFxVcJTxZ2weLQ0bkIjr8amk3gayhogiEzobRwB eaCtU/1CRgdSgQcxcPGceu8X88K/SFsZ77SJEK+LPmJyYKFqHFZaSZmFQDol6mR0nhhN YX/DpUFrp2Yu16QRvDFTAl9lQXHGDV38Vg0pBonZ76b99X3BUMUB/XMFoT60jz2Ss0Qm rz8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dR8SwI7xo4O3PMMdZC16ZxBjI2bA95Vf3wk63lcfA2M=; b=R7DxZ0pJetdlJeCsX+l5pBoc8m9s8GiFoW57Nk1+YRS8c1fcVsO+oZuUQ80iCQseFD kLYNi3jYQzWBfCznI0DOEe0aqAhhaNTcOfPxKiGfa+b0WoJlM7HkfQo47cD4tj10Z+wU DozuFJ6YQTy9KMrvngbq4WhoQAWDCpkz1LYpIOVK8xUGYCYXabKzDQwwvGxeYayQJm+w 2mlSQ1UmPXZTZSytjVYkr6VQn1litej7tdP5hsimOK2IUrZu/wr5Eg1F2hFFomgjLce3 ZH5nC2K6boVKWQerh+9uen3BOIqiw1U9KL9x3H0SS0V+wnXB1K4Rpctvv/bTKCBW9p3S 4kvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=oLE+6BTJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x36si22131066ede.190.2021.09.28.08.31.54; Tue, 28 Sep 2021 08:32:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=oLE+6BTJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241566AbhI1PcC (ORCPT + 99 others); Tue, 28 Sep 2021 11:32:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241473AbhI1PcB (ORCPT ); Tue, 28 Sep 2021 11:32:01 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 197E1C06161C for ; Tue, 28 Sep 2021 08:30:22 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id e15so94533682lfr.10 for ; Tue, 28 Sep 2021 08:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dR8SwI7xo4O3PMMdZC16ZxBjI2bA95Vf3wk63lcfA2M=; b=oLE+6BTJ5k6LXPcuEw3+RcYe2XS/f5mJxXbP1VwlUDABUlzPMLhayafCLsVhkX2NqF WpFRgFX/2AhQHcslRSbaiUTVmtqeWR77wqGhY6fXPVo2MlcYMklHxpFc3gCUuHFGZMa1 5vXdtqUr0EP1jiCZdwLQcHo5V2ZvbH+OdwXMX1fqCmHkwZ27q8UB1hOwMjiL6nsOK1gg Ee0CFm9sNd0klFbzde3PVksW/1cxH6cd2mGS03a9Z5V04qklSqZuXpdM/eXNuiQWuKe6 CS2N4+6Jl9jqTqkXWMcKV/LLzNX7vY/pvky0ao4puIdmv2fHcq51pAmgfToDyk4kf94A cjfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dR8SwI7xo4O3PMMdZC16ZxBjI2bA95Vf3wk63lcfA2M=; b=XYwHpLRDZrmh8XKgGd1cHiQZkfTsjfwBEAqIjD3vwPkCRfyU4W0p+hWi58Acvp9Xx5 ljL6Kqw5Bl7QIChXMojK9hkSAS5ZBgw4n+mzyCPYE1ax5jmfG8xW4/9l7mVT7y+0vr3D vmB5ndUDP1ua0cWk3djsj6/1rfra19n3Uio7iDXHNmHjohtRjGESnwD9s9fwrrWvo/kO X9o3YMCkhEreeI0ukSwEaSptfiohUokhpwXM/TRBBbqABAI93v2TkUPJjWUilmo0BZhB 9sHL/vm4FHgn+fNAWWPT0LGwnxlTlNQiejzNlSzJHODoSw6KbR7EhUbFMsBoujKS2x8r Ls/w== X-Gm-Message-State: AOAM533rT18jkgB5AEWg/p1OQkc9WnvdPsd22uUJHsB7Sk9htZCFw6Dz G6Gj4Iru5IO6Z5N75aQJaULcfywdCNCjuXpEfDP+jA== X-Received: by 2002:ac2:483b:: with SMTP id 27mr6151373lft.644.1632843020212; Tue, 28 Sep 2021 08:30:20 -0700 (PDT) MIME-Version: 1.0 References: <20210914164727.3007031-1-pgonda@google.com> <20210914164727.3007031-2-pgonda@google.com> In-Reply-To: From: Peter Gonda Date: Tue, 28 Sep 2021 09:30:08 -0600 Message-ID: Subject: Re: [PATCH 1/4 V8] KVM: SEV: Add support for SEV intra host migration To: Joerg Roedel Cc: kvm list , Sean Christopherson , Marc Orr , Paolo Bonzini , David Rientjes , "Dr . David Alan Gilbert" , Brijesh Singh , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 6:42 AM Joerg Roedel wrote: > > On Tue, Sep 14, 2021 at 09:47:24AM -0700, Peter Gonda wrote: > > +static int sev_lock_vcpus_for_migration(struct kvm *kvm) > > +{ > > + struct kvm_vcpu *vcpu; > > + int i, j; > > + > > + kvm_for_each_vcpu(i, vcpu, kvm) { > > + if (mutex_lock_killable(&vcpu->mutex)) > > + goto out_unlock; > > + } > > + > > + return 0; > > + > > +out_unlock: > > + kvm_for_each_vcpu(j, vcpu, kvm) { > > + mutex_unlock(&vcpu->mutex); > > + if (i == j) > > + break; > > Hmm, doesn't the mutex_unlock() need to happen after the check? > Ah good catch, thanks for the review Joerg! Yes you are right this results in calling mutex_unlock on a mutex we didn't successfully lock. I'll fix it in the next version.