From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64434C11F66 for ; Tue, 13 Jul 2021 21:41:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3EE2D6136D for ; Tue, 13 Jul 2021 21:41:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235118AbhGMVny (ORCPT ); Tue, 13 Jul 2021 17:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234947AbhGMVnv (ORCPT ); Tue, 13 Jul 2021 17:43:51 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF861C0613E9 for ; Tue, 13 Jul 2021 14:41:00 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso96476pjp.2 for ; Tue, 13 Jul 2021 14:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vrEJ0IT39G6kebRkO06W9h6TS+oFcHPIOO8VkXk5PLc=; b=EkBKXPjG/EViWsVLjIMs74wrEbBjOH730bpAeV5qYqG+B0UneYTAvPtkjZLsA1rjv6 w2jUhzukYTGEkN5V53eb/WR+qauAqVGwKHRRomK6w8HAJDVa0Y0cmRRMC6Asrnhn+dmU Pr04MUNXrEiPdlhTCKD8He9wd3WcedkSp1HqdGVZ3LTxko8dgwSkb+NL9zGmwj82jEX+ 4jUVWseWvcjt8nyo7DdqdbtPvzrQvh+WFPcKRKVuKqOh2es/FcR+fMIjPVhVOr/K3/O8 SIBH9iBaiwOcJai9B60fJtXdnfezRqdn2ElMDDx4s5kmBvZSFew0evOajJJwFrisVLl2 qfqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vrEJ0IT39G6kebRkO06W9h6TS+oFcHPIOO8VkXk5PLc=; b=QReF9q+A94H2rI1cJezwntZtUdE64oPcu41g04N8GcbfSaaMKWmGo1BTbaKGAFlS3S L8udfITkrrAOq008htp9YbBKbWvyPy4ixyKY4bGUlu0AeeW90LRp79EuhV8UWxRpWrXx s3fuAZSvmMn9IuHpVoPHO7iXwsiZ3E9PKOBYobUOddev3YegIw4RVY2LXsfhLtcd1853 5WCft59aAlwpqyWVvPtrpQp5fDuB0ZnBWnnRabaOvCzCKAYMQE+A8D9vahpFlwR9eHgf OwqTBbWx18M4kB0IjL9sCy2SYL1BQswNuES57sZZQBCp7tb1tAZ+GH2QNNj3l7VuvtNs Ci/w== X-Gm-Message-State: AOAM530gPDk6FBsxrQp8j8UsmsziOx42QE6rJO3mcZvF7AF0OCzW0tGx rw5rr9VBy/LT8OjSQoqneqWyug== X-Google-Smtp-Source: ABdhPJweJYmPzlJGgylcdQJabbQixGutCZcMF0Rp33GsEdP6B9GDMskxSoz4hKihkerQAW4A12A+iw== X-Received: by 2002:a17:902:e852:b029:128:e56b:3227 with SMTP id t18-20020a170902e852b0290128e56b3227mr4995350plg.81.1626212460062; Tue, 13 Jul 2021 14:41:00 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id x128sm114459pfd.167.2021.07.13.14.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 14:40:59 -0700 (PDT) Date: Tue, 13 Jul 2021 21:40:55 +0000 From: Sean Christopherson To: Peter Gonda Cc: kvm@vger.kernel.org, Paolo Bonzini , David Rientjes , "Dr . David Alan Gilbert" , Brijesh Singh , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] KVM, SEV: Refactor out function for unregistering encrypted regions Message-ID: References: <20210621163118.1040170-1-pgonda@google.com> <20210621163118.1040170-2-pgonda@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210621163118.1040170-2-pgonda@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21, 2021, Peter Gonda wrote: > Factor out helper function for freeing the encrypted region list. ... > arch/x86/kvm/svm/sev.c | 26 +++++++++++++++++--------- > 1 file changed, 17 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 46e339c84998..5af46ff6ec48 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -1767,11 +1767,25 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) > return ret; > } > > +static void __unregister_region_list_locked(struct kvm *kvm, > + struct list_head *mem_regions) I don't think the underscores or the "locked" qualifier are necessary. Unlike __unregister_enc_region_locked(), there is no unregister_region_list() to avoid. I'd also votes to drop "list" and instead use a plural "regions". Without the plural form, it's not immediately obvious that the difference is that this helper deletes multiple regions. Last nit, I assume these are all encrypted regions? If so, unregister_enc_regions() seems like the natural choice. > +{ > + struct enc_region *pos, *q; > + > + lockdep_assert_held(&kvm->lock); This locked (big thumbs up) is part of why I think it's a-ok to drop the "locked" qualifier. > + > + if (list_empty(mem_regions)) > + return; > + > + list_for_each_entry_safe(pos, q, mem_regions, list) { > + __unregister_enc_region_locked(kvm, pos); > + cond_resched(); > + } > +}