Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4854832pxb; Tue, 28 Sep 2021 05:43:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPV8ZaeVHCsVTkUp3JBLzWDU4V4kc2ohtwd6l22MrwnuZYNx0jV3AlxMeoI3HuIalJ7GTV X-Received: by 2002:a17:902:9b88:b0:13e:55b1:2939 with SMTP id y8-20020a1709029b8800b0013e55b12939mr382329plp.80.1632833036669; Tue, 28 Sep 2021 05:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632833036; cv=none; d=google.com; s=arc-20160816; b=EeCWKA8qB0hW1ppnqR3gfZ3fvgreg4DiNTFJcHA0J5t8xFwwVk1ZhrGBGNaOZIGdyH GPOy38+RKVuzUmByRo0kpM1winrisTSJ8YIzNp8TFebXVO2sLNaL9YWE5NszSPJfndVa njLElJH2De2MSrySa/hWm7RVpZiVCAoqYb2Gfx0kkJUfZbeZKhmZh0xUHIXfgCs85h+E NNorXtUpiNEhZtHtIdiCIehNDodfhnNJNcq5PGLghbqGYeLmJ/EZCotxPNipJpddpdDl UiDN2Tm2fO3/o0ifBGxPjefSxZwVmEDIMzSsPKkaxf0ryIFq7nXe1tRMU9ZeTZg4OIGf I9tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=AKy4PmTX9At/NZgvPHbutUdV1SLEgf3GTRayMzSwZTE=; b=UHwsfe+cOqb7vt2winxFtr6nhx8M7yvWsQ25q6fKM5w/j39eQyccRlIXufPHH7GcaX 4RsE/fQNvbhmgf2f2coNzaqTxjAMTolcPt/nJhGxNdEZf648/Z52XHT/ONpTepxQEdpF I0uazbKxQftImRKS3gbsazr15/LHJc9MfCE7TgtWiBofJLqTk+oowrvILBvU0mrb6MeZ o9GjR31DQIZihypaUeGDNDUKqjKto6wUH9+eUOijzDovAEEY0RrvQY0Vsvh08I73GY/5 3n2R2Wf7BAHYK7JUgEv93IR7BV2mUEfT73e+i40+SKYvBtVDorPAC6H0uB5kA0q7Bdws zy1g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si21988279pfk.157.2021.09.28.05.43.43; Tue, 28 Sep 2021 05:43:56 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240712AbhI1MoH (ORCPT + 99 others); Tue, 28 Sep 2021 08:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240637AbhI1MoF (ORCPT ); Tue, 28 Sep 2021 08:44:05 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 629AAC061575; Tue, 28 Sep 2021 05:42:26 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id B2248208; Tue, 28 Sep 2021 14:42:24 +0200 (CEST) Date: Tue, 28 Sep 2021 14:42:19 +0200 From: Joerg Roedel To: Peter Gonda Cc: kvm@vger.kernel.org, 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" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4 V8] KVM: SEV: Add support for SEV intra host migration Message-ID: References: <20210914164727.3007031-1-pgonda@google.com> <20210914164727.3007031-2-pgonda@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210914164727.3007031-2-pgonda@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?