Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4605931pxt; Wed, 11 Aug 2021 09:38:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmwIV7ZxcmsalOa22MsSfWv/WYNl6u42gThGtErS67hfCWlsWgjHtyB7MhUm0t0gEJnY8u X-Received: by 2002:a17:906:eda3:: with SMTP id sa3mr4574452ejb.451.1628699913156; Wed, 11 Aug 2021 09:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628699913; cv=none; d=google.com; s=arc-20160816; b=IILlwNvepJekCIa4PBXsxpVlGruQ85Qxg22Yw8+txpS58ja1/69bINGzkDKeTGieFX dLlSc6N0Nha13Y6Jpqwdo5B4KcfGKpNOjmHPgR/uNZ2Ork+J1wz2KQdYSzs1V9RYSP1v 6og5UY8eFemw5aigEj+LFGQWKSKXrwmM970KvDSXfeHfvmO+dn3s/bqWLCeu7X9fH+2O ON6BbNZdKQMfoMdUmgDI/+RpSZhBd8eTkgvFpcsSGGHaeBOLyHQB0QPxMicHR74HbIUa 4EF7Jy/3xmLp+iEH4Qqshacplc8YjqEp9Eqvj3upKpy2KMR5u7WB6G4TESf30pceUz1q J4iw== 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=MiyXaKuo5MKFz5xTuKgPxPuaaij2HCFYcE1MAYz0REg=; b=0oaLPIDA0aCGcij2p+zKCYVN7Q5v3ohY6tzA2t/zidt8nrhS6k0ChPmprEQUie9j+V K4z2rK1F/SWjeqam9wkzy14cM2x5nhaTU/TqhEBcRXw4c1rPZdochRx/q6aOxLg1TzVB 5ts6IUEO7F2WSYOf0ULPHpD63nSqdZ9GB+Q/tqzx5JZ5tHrz9tztgBQvrnEWdRLmDocq 6BlP493YTSmMaOkuwjikCwLj/xWKgPsQuljXDjq5xUQ1MyUawG5z4Wfjec0WIT+QRDjG CM9fec69wRfX0cUHK0DTS2CPG6VJjxkuzD3VCx11cXVUo3J7GXxyv2rZ7xYY4VejEYIe +Juw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="qzk/GM33"; 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 ee39si6335454edb.579.2021.08.11.09.38.08; Wed, 11 Aug 2021 09:38:33 -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=20161025 header.b="qzk/GM33"; 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 S230312AbhHKQeg (ORCPT + 99 others); Wed, 11 Aug 2021 12:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbhHKQed (ORCPT ); Wed, 11 Aug 2021 12:34:33 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D71DC061765 for ; Wed, 11 Aug 2021 09:34:10 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id a4so3453451ilj.12 for ; Wed, 11 Aug 2021 09:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MiyXaKuo5MKFz5xTuKgPxPuaaij2HCFYcE1MAYz0REg=; b=qzk/GM33ZCdtZbJZtJAJP/kWtgtTjQwNcsmSSAYqiffShG7oeLVm7tOQVHINHXsoLq 9yWPnQuRcQvO4IAUfgcxAW7CMdJCXasEmfFWEzHNwNv20ottnoat8QezWCS/nXvvykGE Lzb894TfheLpGH5YyB2IzuFezJgPbfyNde+6Zy9U1hbZ1tQppF3RrUnNP80Hfy9/OaDv UklNV67dzGuO2Ybv20/Vwq1dXd028bYefpz/bf3O0/w8Cm6VR32Wdp55ZqeS2gpww3Ej AuYUAJw/UMgfwC2SmzJho8Y8cEuY9cGqzpv95LK9F8UiBfKgd6ROYTng30Mm2EQ7g+EY Xu0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MiyXaKuo5MKFz5xTuKgPxPuaaij2HCFYcE1MAYz0REg=; b=TLVXKwLavlK0af+438UOaEu04OExt6Ibgl2Wx9UePTFvfNmM0+k2TXAy67RqFBqj4P flvvJqOeG/CDEb47CGgDK3Cc/WPW1EPO3yWrUI8AYVTbIH9jtDJipNjJxcg//L+ui/yo OHAJFwyQ6q964vWKXMdBb1g4mW8G0HUv+DHW9tiVVagfFi075ogwX2bqdfwmO/qUQfad NoJseo3qEjqdG7tmTnPuz7T0V9Di5Mftclog+ahXM8MFsxfnNlXCPQFvGVzr6C1itpvY rXaT9c6bPTi/PqXDgmhe7U8HWf9B0L7SmfwgS5/DOPa6s9Iv6pZVDHW6nXbPokQjVHy0 TQSg== X-Gm-Message-State: AOAM533AY3RCXoCikuVyrC8H0M7emLjAaOnFfI3mYfOyOwVhdDAjCWcN O6FkkOlUEdSrc/QThHI8Ms2peGtqN0v0gvGn2ejEuA== X-Received: by 2002:a05:6e02:15c8:: with SMTP id q8mr612495ilu.285.1628699649398; Wed, 11 Aug 2021 09:34:09 -0700 (PDT) MIME-Version: 1.0 References: <20210810224554.2978735-1-seanjc@google.com> <20210810224554.2978735-3-seanjc@google.com> In-Reply-To: <20210810224554.2978735-3-seanjc@google.com> From: Ben Gardon Date: Wed, 11 Aug 2021 09:33:58 -0700 Message-ID: Subject: Re: [PATCH 2/2] KVM: x86/mmu: Drop 'shared' param from tdp_mmu_link_page() To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 3:46 PM Sean Christopherson wrote: > > Drop @shared from tdp_mmu_link_page() and hardcode it to work for > mmu_lock being held for read. The helper has exactly one caller and > in all likelihood will only ever have exactly one caller. Even if KVM > adds a path to install translations without an initiating page fault, > odds are very, very good that the path will just be a wrapper to the > "page fault" handler (both SNP and TDX RFCs propose patches to do > exactly that). > > No functional change intended. > > Cc: Ben Gardon > Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon Nice cleanup! > --- > arch/x86/kvm/mmu/tdp_mmu.c | 17 ++++------------- > 1 file changed, 4 insertions(+), 13 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index d99e064d366f..c5b901744d15 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -257,26 +257,17 @@ static void handle_changed_spte_dirty_log(struct kvm *kvm, int as_id, gfn_t gfn, > * > * @kvm: kvm instance > * @sp: the new page > - * @shared: This operation may not be running under the exclusive use of > - * the MMU lock and the operation must synchronize with other > - * threads that might be adding or removing pages. > * @account_nx: This page replaces a NX large page and should be marked for > * eventual reclaim. > */ > static void tdp_mmu_link_page(struct kvm *kvm, struct kvm_mmu_page *sp, > - bool shared, bool account_nx) > + bool account_nx) > { > - if (shared) > - spin_lock(&kvm->arch.tdp_mmu_pages_lock); > - else > - lockdep_assert_held_write(&kvm->mmu_lock); > - > + spin_lock(&kvm->arch.tdp_mmu_pages_lock); > list_add(&sp->link, &kvm->arch.tdp_mmu_pages); > if (account_nx) > account_huge_nx_page(kvm, sp); > - > - if (shared) > - spin_unlock(&kvm->arch.tdp_mmu_pages_lock); > + spin_unlock(&kvm->arch.tdp_mmu_pages_lock); > } > > /** > @@ -1062,7 +1053,7 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, > !shadow_accessed_mask); > > if (tdp_mmu_set_spte_atomic_no_dirty_log(vcpu->kvm, &iter, new_spte)) { > - tdp_mmu_link_page(vcpu->kvm, sp, true, > + tdp_mmu_link_page(vcpu->kvm, sp, > huge_page_disallowed && > req_level >= iter.level); > > -- > 2.32.0.605.g8dce9f2422-goog >