Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp5527240lfu; Mon, 28 Mar 2022 16:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTTR4jkN6aOEZID5eD+s1/J9dTM89J7tVkbf21nmgl/agltEE/eUEO7lMG4BkFxRd8Unfu X-Received: by 2002:a05:6808:bd2:b0:2f7:59fd:2f1b with SMTP id o18-20020a0568080bd200b002f759fd2f1bmr757906oik.217.1648508494920; Mon, 28 Mar 2022 16:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648508494; cv=none; d=google.com; s=arc-20160816; b=BVfOWR6cPGWTnbEebXm6US8Mo8NvQ4jpbBBwX+aHEOBVGSaC38Cpvx/i51EidvMjTM T6MXQq2i8s5AjkAvt/Jn3KZRIY7wBGH9SUae7sP57oXYeBLESouJA3pOtXdfCpiy/6N1 xLayFjWIH5ADE7AL0gawcO102Jrzj7REzQhA9/gVs/FDP63VFhP4yGjnkxGZENnZNfQh uuohCyvVBLzHBsG87tzxuUVFRnIvu7tItFgTHF3kHVudYYcndYBtOiVC64jMJ0wnP8Xs Lx0mafjlf4YQ7/TF1CtHSflrEM+yxjrAjPiaC78e2QM/Mjq+2OXYmltmsg2OQ/3nGp7p NcLg== 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:dkim-signature; bh=JXiZLyVcTv3cYa39mjggFsDeKk+fw8s9JjdGqHNpG80=; b=F7R6GkIHRBo7g4UdHCrQ3DwFEpXkbyX4QUvQkRR+vL6poe8cusLeUrOLSWyBCp51bS frz2pTQBx6Fqimy0J3iK6zygTOR+IXOEOE03O3rsb/kyyDGpyGNbzCpXYBKJb/CGtS4X oQFXmYdhLOhNjesU+9RKO3WuYVyadR6ojq+YBGLFUL/t1NYUp+dF9pf9EgcPAeabTDgr lZPjxjAjPIy79Jz7VqMPK/LNg3SauyA0S7rmrBShV8M5L/x4lBtoXb66Uekw7AEr5NJ/ l/EOGY1vSgRnd000NhKnh98u1ba2sZm/lX7Y9vetfxkVskA9LaYBU+lkjQnBUOWBz/FR eqnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=bClxg11N; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 184-20020aca05c1000000b002f75ceb8f93si2808625oif.94.2022.03.28.16.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 16:01:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=bClxg11N; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E4CC28EA05; Mon, 28 Mar 2022 15:00:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbiC1VGM (ORCPT + 99 others); Mon, 28 Mar 2022 17:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbiC1VGJ (ORCPT ); Mon, 28 Mar 2022 17:06:09 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A3557B2E for ; Mon, 28 Mar 2022 14:04:24 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id c23so15813274plo.0 for ; Mon, 28 Mar 2022 14:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JXiZLyVcTv3cYa39mjggFsDeKk+fw8s9JjdGqHNpG80=; b=bClxg11Nnfo7j1cKJwJ4jY71QexPwYK77hxirTMRK3jKmt7vBlue13dO8t1feTRUP7 InfZvOXFrGDgFXTLHDyRR47C9NgqeLQ/4nAaWWENT3uoPTQQXHMYsKnZrpoie5KiZRuw vDHgvU0REass3htGtzM6CsDEO44b+obMRjsYr54WXw8oiFmIuD8S9OcD21UI0UPjTEF/ hB34HAoQz/TYryhjN+BKoKJMVa0xTPB6NPgit6zM08EHLygeZgi1fvZpEVw5OWP3kfyy ml/A2fH0Ql4WMRcmt2DOrwpRO/SMmpqfo4EfCwjJHJuaDU4qdxV1mShYhD7s1F8lwZG3 P4fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JXiZLyVcTv3cYa39mjggFsDeKk+fw8s9JjdGqHNpG80=; b=wmZMHza2Brn2Cq5Jnmqdyixrol+YcFEFguUZ/+GcDJK2QskolFdwowmQJOK7h0DhUz GDRyPqsv0N6MAQLSD916W600WVrlt1PuwfXi22mGgEjqmPkfixQbOQaXJL5JJPbqMp2c 8sluQCvaaX3OXRtXeYkkEhVhYwgDiqKkXP0Wt4I5rBU2+yOGFHClfi/L4rHfHcXEXYJJ kJ+sBOHWWVBNN1ia1DLlRQkbGuMvd1uzszf871RXGzzXb6y1dfvIB0GnhisV6dv+BJGX rjk7f54mJ1146T+LcL2T3LVw2+x9YJrEzFFkRe4dfYcjdlvT+h9FX6x17435MCII4CBS t+3A== X-Gm-Message-State: AOAM531pkfuoAP/s5PTTUeM/7/cMtdi7TKJM0pWc/0eJvqQRl3f3Brjb bVBmXp7CxvPLqwCCiOzLPbExdw== X-Received: by 2002:a17:90b:38c9:b0:1c7:1ffb:533b with SMTP id nn9-20020a17090b38c900b001c71ffb533bmr1026681pjb.220.1648501463880; Mon, 28 Mar 2022 14:04:23 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id d2-20020a056a0024c200b004f6b6817549sm18217058pfv.173.2022.03.28.14.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:04:23 -0700 (PDT) Date: Mon, 28 Mar 2022 21:04:19 +0000 From: Sean Christopherson To: Nikunj A Dadhania Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Brijesh Singh , Tom Lendacky , Peter Gonda , Bharata B Rao , "Maciej S . Szmigiero" , Mingwei Zhang , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC v1 2/9] KVM: x86/mmu: Move hugepage adjust to direct_page_fault Message-ID: References: <20220308043857.13652-1-nikunj@amd.com> <20220308043857.13652-3-nikunj@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220308043857.13652-3-nikunj@amd.com> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 08, 2022, Nikunj A Dadhania wrote: > Both TDP MMU and legacy MMU do hugepage adjust in the mapping routine. > Adjust the pfn early in the common code. This will be used by the > following patches for pinning the pages. > > No functional change intended. There is a functional change here, as kvm_mmu_hugepage_adjust() is now called without mmu_lock being held. That really shouldn't be problematic, but sadly KVM very, very subtly relies on calling lookup_address_in_mm() while holding mmu_lock _and_ after checking mmu_notifier_retry_hva(). https://lore.kernel.org/all/CAL715WL7ejOBjzXy9vbS_M2LmvXcC-CxmNr+oQtCZW0kciozHA@mail.gmail.com > Signed-off-by: Nikunj A Dadhania > --- > arch/x86/kvm/mmu/mmu.c | 4 ++-- > arch/x86/kvm/mmu/tdp_mmu.c | 2 -- > 2 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 8e24f73bf60b..db1feecd6fed 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -2940,8 +2940,6 @@ static int __direct_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) > int ret; > gfn_t base_gfn = fault->gfn; > > - kvm_mmu_hugepage_adjust(vcpu, fault); > - > trace_kvm_mmu_spte_requested(fault); > for_each_shadow_entry(vcpu, fault->addr, it) { > /* > @@ -4035,6 +4033,8 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault > > r = RET_PF_RETRY; > > + kvm_mmu_hugepage_adjust(vcpu, fault); > + > if (is_tdp_mmu_fault) > read_lock(&vcpu->kvm->mmu_lock); > else > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index bc9e3553fba2..e03bf59b2f81 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -959,8 +959,6 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) > u64 new_spte; > int ret; > > - kvm_mmu_hugepage_adjust(vcpu, fault); > - > trace_kvm_mmu_spte_requested(fault); > > rcu_read_lock(); > -- > 2.32.0 >