Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1541400pxm; Thu, 3 Mar 2022 21:18:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2TnjJNzHVj4jYhGP3nCvHK4Ku24isrO8Hgevp5hcvWeeQHzy01zzGVzhfNugq24TcmvJ3 X-Received: by 2002:a05:6402:42d4:b0:412:c26b:789 with SMTP id i20-20020a05640242d400b00412c26b0789mr36996584edc.232.1646371113495; Thu, 03 Mar 2022 21:18:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646371113; cv=none; d=google.com; s=arc-20160816; b=IBq0/QiFg2QQBNqGmCNPEf0R1ptxWzV5Uglpfj+4xwP275y05DOj+slREIirjpxkEV ZSCwOQEMm8tyr/Gidmd4ojiC4AxN5mReP0uEOOv7nZLDlLb4U0NTKYcLwaXmyLLtF2Aj Oz49ne24m5bpufnqKz63Q9KzsnJ12gdUwl2QRLWScZOv2iPw8pjNLG4Qs0ZcS2H75RSm eKoFT67gpLWYekpYG9qRhwYsUzB/ljKc1djYMjOqbbQAmeMBno++rJ+HyJa1QFnK5+np JT7LUs4wS/tX8ILGGuo/Q1+rVNPjS3JTsazHa+DRPpnh1v+dbyAeywf10STOQIWG4m0M TaOQ== 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=BTYLb9HBGbhFly2fPG2qXLCkv8yykoYepo3XTTdlldU=; b=kfkL4rnjBccT8nMLYiCHjwo5JhhRckJfgCYPkSdRYTxvz7zku5/T7b4cU8XcT94fdG 56rgluY1yefPzDho/N+q/uLV0KfxA7KAOuBYTRVqHTpzhIFWyTlKFdYMOeenx0aeC1KA Du77/FhYyfNY1HpetePrvYPb8NKS00R/5cq7iyvGat92Vfi5ELrcYUYexTTotL2XW8Y6 F87TdPuvYBvP11GE9foQSqdXuLczzx6PCAICOSFisQ50lyBa3T+bkh5ilhoI+SnZcHmB ONpM/h0jGgXa7N9gfXhSWa+9EE2AVbNui0wgml7MeXRDo8bNsFTTwuUMOpXrOF8TdTMX dsYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="hMNEn/Gb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd12-20020a170907968c00b006da8d9dcba5si2669087ejc.689.2022.03.03.21.18.10; Thu, 03 Mar 2022 21:18:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="hMNEn/Gb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232144AbiCCSJj (ORCPT + 99 others); Thu, 3 Mar 2022 13:09:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbiCCSJh (ORCPT ); Thu, 3 Mar 2022 13:09:37 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F7CBE0A2A for ; Thu, 3 Mar 2022 10:08:51 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id w37so5220918pga.7 for ; Thu, 03 Mar 2022 10:08:51 -0800 (PST) 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=BTYLb9HBGbhFly2fPG2qXLCkv8yykoYepo3XTTdlldU=; b=hMNEn/GbmsMUtg4oxmhbIXRQPVu7NbT/WnAC+/jn+WiRKSM7xs9ti7I+wV1P4R2KS6 WyVaAQBYn8vI35ur6gZJAJaQMN+WKs4MtDZsOsg3sgrnOB+a+83MvWTlsNKCDHwTbVNs AuNKx6JVDpCoQvMOaz4KETYS9boMeymCUkhtZW9QSbQ3vdqakdm//NbGnRRYgYv3Z0lq puUAUv3NNNaHd8SeCesRLc/m6vEaOpcbH3NUoLG6sfuyIVCzVUldPEUSFQcO3DYJfflj QgUdSyRbbMGqeQvDzGYp75lw3LygYoCXG/K8Uc9iyIT3sBJVfDqdm7XqMMwDJnTAqIMZ jMfw== 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=BTYLb9HBGbhFly2fPG2qXLCkv8yykoYepo3XTTdlldU=; b=5KYLG8vlVUd7Myc1W9k0lr1MbEzSjrH38y2C6+S0ZajdD7CoAtRN5gVsjllbiyfMd1 aEpczb78XtwEhVGyLA5hqKte6PKatwhkGW5Xu+vhfDUMGG8a6qvxqxFaZmPcqD3QUmfE W0J8lsEHDT+JOgi1DNqVL9CM77uEwJfdJrl+DAdw1CJfEo+XRC5BrhwTheOJSMzuVrVX D7BK+ntZr5S3MfHeqRXhOJu5u3A6dtYGMVJ+DP0ZZWqIJw7AIzeV5YNf56MM0ANrdPz3 qK1rEane6H7Igidf6mdtA8VVih//HgET6X7Mw+OfsGLw/pYGMfBgw3/CuNdahJNLDGfa KSvQ== X-Gm-Message-State: AOAM531Fnrz+9BdSgI/NG1fs2J6BOZUGit/euewZ/PVZVbZEnHR7fD7f KjlPs3JBXO0200mKpJv6ANqGzw== X-Received: by 2002:a63:1c14:0:b0:36b:28ef:f8ce with SMTP id c20-20020a631c14000000b0036b28eff8cemr31681899pgc.96.1646330930904; Thu, 03 Mar 2022 10:08:50 -0800 (PST) Received: from google.com (226.75.127.34.bc.googleusercontent.com. [34.127.75.226]) by smtp.gmail.com with ESMTPSA id 124-20020a621682000000b004f6a2e59a4dsm963540pfw.121.2022.03.03.10.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:08:50 -0800 (PST) Date: Thu, 3 Mar 2022 18:08:47 +0000 From: Mingwei Zhang To: Sean Christopherson Cc: Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Ben Gardon Subject: Re: [PATCH v3 08/28] KVM: x86/mmu: Batch TLB flushes from TDP MMU for MMU notifier change_spte Message-ID: References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-9-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220226001546.360188-9-seanjc@google.com> X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Sat, Feb 26, 2022, Sean Christopherson wrote: > Batch TLB flushes (with other MMUs) when handling ->change_spte() > notifications in the TDP MMU. The MMU notifier path in question doesn't > allow yielding and correcty flushes before dropping mmu_lock. nit: correctly > > Signed-off-by: Sean Christopherson > Reviewed-by: Ben Gardon Reviewed-by: Mingwei Zhang > --- > arch/x86/kvm/mmu/tdp_mmu.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 848448b65703..634a2838e117 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -1203,13 +1203,12 @@ static bool set_spte_gfn(struct kvm *kvm, struct tdp_iter *iter, > */ > bool kvm_tdp_mmu_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range) > { > - bool flush = kvm_tdp_mmu_handle_gfn(kvm, range, set_spte_gfn); > - > - /* FIXME: return 'flush' instead of flushing here. */ > - if (flush) > - kvm_flush_remote_tlbs_with_address(kvm, range->start, 1); > - > - return false; > + /* > + * No need to handle the remote TLB flush under RCU protection, the > + * target SPTE _must_ be a leaf SPTE, i.e. cannot result in freeing a > + * shadow page. See the WARN on pfn_changed in __handle_changed_spte(). > + */ > + return kvm_tdp_mmu_handle_gfn(kvm, range, set_spte_gfn); > } > > /* > -- > 2.35.1.574.g5d30c73bfb-goog >