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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 1A3D2C43461 for ; Tue, 6 Apr 2021 18:59:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC4E261399 for ; Tue, 6 Apr 2021 18:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233884AbhDFS76 (ORCPT ); Tue, 6 Apr 2021 14:59:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbhDFS75 (ORCPT ); Tue, 6 Apr 2021 14:59:57 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0841BC06175F for ; Tue, 6 Apr 2021 11:59:49 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id f29so8591210pgm.8 for ; Tue, 06 Apr 2021 11:59:48 -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=o/K/k7TMA0dim45MUt35sdwItRBULQE49yHai9MnD1o=; b=KzmcnGjurr5EEPEluehzMcYb2wZZDh8gpR5aFdc2gPNCZhYvrxHbISKeCPlLNRFxS9 CMB/peeYBZORNXtSyfCZtbWA0FOztd+t2tmSePqLeQ1zcjwtZl/2pDj9LPA+GJGMZw4G h4XS89UU36vddvcTKG7ff18HjenYr0SbCgh5T6lj79/rzadvUosYaZDtUb8t4InD7X98 Wsf4r+xpGTeipqLaCXZ408dzon6D9fD86lcKNReq3vzdRDFtDh7ft10q12HOmOvHFtDe EjetBvNwCY2IPS0TLRcdf0TGnXoYBH6K49vGgfGJ8QIxuDO6NSheZrGTkH66TQUSg+oN Enig== 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=o/K/k7TMA0dim45MUt35sdwItRBULQE49yHai9MnD1o=; b=JZSnHy9k3z2T7ohNiEJgz0sASBtWEkrC2sif8XrXWLkHqIPwzcH6sVgXmMXaSG3IIZ h4Os+qRPbKsDoBVnzY6yB9VN0S5Prz2LSjKSSGDP6kyP3r0NJbUOwBVYHYS/GSDQhwOq jDAc5DMlFuPiFUilKK5BnO1PE8dVWiiqusum1LxluisyI09t9OW7z6ZcrTIqtRWtjIHX wLCROmaRQBc4aR39RGg9c0lvGpoT0Odnx9HwiCsOMWBJh40RO6/BLHYvyzUBFRVHsshm KrWh5srFP71WiXy1To2PgRNBWdSWMkt4mFTaOwWHRpiAn8B7SaD435pqJFUmUB/0T/UG v0pQ== X-Gm-Message-State: AOAM5327I7NHANPUaHIq2IxiNhH8ilo0K8UyLSVLSFSEzkzcAIKg46Jc bz5X74UWtCeaNkk2xm79SJs1gkQR9kj50g== X-Google-Smtp-Source: ABdhPJyIk5vGhXdq5zQumhsts0/ms82m7PMKls76aAMgOHLCSFmyTEgoaXIvPjhMxKbNVnZrFVtveA== X-Received: by 2002:a62:1c93:0:b029:1fd:2216:fb45 with SMTP id c141-20020a621c930000b02901fd2216fb45mr28502785pfc.13.1617735588287; Tue, 06 Apr 2021 11:59:48 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id hi21sm3087454pjb.36.2021.04.06.11.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 11:59:47 -0700 (PDT) Date: Tue, 6 Apr 2021 18:59:44 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] KVM: x86/mmu: preserve pending TLB flush across calls to kvm_tdp_mmu_zap_sp Message-ID: References: <20210406162550.3732490-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210406162550.3732490-1-pbonzini@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 06, 2021, Paolo Bonzini wrote: > Right now, if a call to kvm_tdp_mmu_zap_sp returns false, the caller > will skip the TLB flush, which is wrong. There are two ways to fix > it: > > - since kvm_tdp_mmu_zap_sp will not yield and therefore will not flush > the TLB itself, we could change the call to kvm_tdp_mmu_zap_sp to > use "flush |= ..." > > - or we can chain the flush argument through kvm_tdp_mmu_zap_sp down > to __kvm_tdp_mmu_zap_gfn_range. > > This patch does the former to simplify application to stable kernels. Eh, that and passing flush down the stack is pointless because kvm_tdp_mmu_zap_sp() will never yield. If you want to justify |= over passing flush, it probably makes sense to link to the discussion that led to me changing from passing flush to accumulating the result (well, tried to, doh). https://lkml.kernel.org/r/20210319232006.3468382-3-seanjc@google.com > Cc: seanjc@google.com > Fixes: 048f49809c526 ("KVM: x86/mmu: Ensure TLBs are flushed for TDP MMU during NX zapping") > Cc: # 5.10.x: 048f49809c: KVM: x86/mmu: Ensure TLBs are flushed for TDP MMU during NX zapping > Cc: # 5.10.x: 33a3164161: KVM: x86/mmu: Don't allow TDP MMU to yield when recovering NX pages > Cc: > Signed-off-by: Paolo Bonzini Reviewed-by: Sean Christopherson > --- > arch/x86/kvm/mmu/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 486aa94ecf1d..951dae4e7175 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -5906,7 +5906,7 @@ static void kvm_recover_nx_lpages(struct kvm *kvm) > lpage_disallowed_link); > WARN_ON_ONCE(!sp->lpage_disallowed); > if (is_tdp_mmu_page(sp)) { > - flush = kvm_tdp_mmu_zap_sp(kvm, sp); > + flush |= kvm_tdp_mmu_zap_sp(kvm, sp); > } else { > kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); > WARN_ON_ONCE(sp->lpage_disallowed); > -- > 2.26.2 >