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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 8F281C433DB for ; Mon, 22 Feb 2021 16:26:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D3CA64E61 for ; Mon, 22 Feb 2021 16:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231460AbhBVQZs (ORCPT ); Mon, 22 Feb 2021 11:25:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbhBVQZk (ORCPT ); Mon, 22 Feb 2021 11:25:40 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3343AC06174A for ; Mon, 22 Feb 2021 08:25:00 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id o22so126553pjs.1 for ; Mon, 22 Feb 2021 08:25:00 -0800 (PST) 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=K8Mk8DPpk11B6V3YwuQN3+iAtbjKIINrpZOMJr9ijMU=; b=ZkL+DPyOhtNNe7hZI9CaKbe4ebR0w/c08TMwcW6jEWxnEH8r794ZleXZWoZ/UR0m9l /JvwszOIsqxGcoQusTcqqjnSjevmzjijIqmibZWhNlf1fAH+fqB2XaC9yYLNGSgQajKW cQ37mvXb34+aOOxfrJiSDd0duyNERIQhiKqe1mF+9oUWIOq5QI43wZI8wjHcqYbkkeNz F74iB1b0pF2iLrhK6gzgmonIkdXMBmp9UGOP+w4UrVRBbDRpQmc5IjIAIQwXpNnoKanf hCRm8lc+Mszq2AP9WNUUdxblVMsJd9jJlh10sSOCswStuXopFHTvKoZcecsf/gsAVlr3 E8CA== 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=K8Mk8DPpk11B6V3YwuQN3+iAtbjKIINrpZOMJr9ijMU=; b=rld7rHxxWSb77s/J06a4Ss8IIYm/qNpapKEWHM6ZGn53p5TmmZK+8ZvM/fxJLar9ii trTUYwgarDVL7gJF4JaaQ9B1/qQNMZQqefqD/oUQYBMsktLNilZNt0fD0d8FoAob5Omi vsiRFNgfQiWVY0rYUGp6Fr489P+yGXLGkfGrfldcvvO55hZ8okuw0IcOk3zYpVH4OipO kzhgyBeHX/rmAVjsqZ/lV67FipBxJ/v+bZAZgi6Se3EzdxEgDxXXl4TtU1bwmI8bm3gm VbhhfFdG5R8+Gd4ny+PCjH8mFJ9uMfxV/qWOUQ8l3kPTCyN+ii2/4gwYxEiqG/09HxPM KE7w== X-Gm-Message-State: AOAM530/FP9XmzknfEIvdISNtoS0MwwSpZ40hJ1LMu7pWjcfizLAOFFK lqhL+5N3sZ1MJZs7UUiwD+IhBQ== X-Google-Smtp-Source: ABdhPJzpaRZ20ovy1dpVfBdxXc3ZVF23iR3XDePJsjQUoeSVBm8Osbw6p/Oa6Rqwlvu7+JfquMJWyQ== X-Received: by 2002:a17:903:1d0:b029:df:d098:f1cb with SMTP id e16-20020a17090301d0b02900dfd098f1cbmr23104083plh.49.1614011099559; Mon, 22 Feb 2021 08:24:59 -0800 (PST) Received: from google.com ([2620:15c:f:10:655e:415b:3b95:bd58]) by smtp.gmail.com with ESMTPSA id f2sm21929378pfk.63.2021.02.22.08.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 08:24:58 -0800 (PST) Date: Mon, 22 Feb 2021 08:24:51 -0800 From: Sean Christopherson To: David Stevens Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Huacai Chen , Aleksandar Markovic , linux-mips@vger.kernel.org, Paul Mackerras , kvm-ppc@vger.kernel.org, Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda Subject: Re: [PATCH v4 2/2] KVM: x86/mmu: Consider the hva in mmu_notifier retry Message-ID: References: <20210222024522.1751719-1-stevensd@google.com> <20210222024522.1751719-3-stevensd@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210222024522.1751719-3-stevensd@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Mon, Feb 22, 2021, David Stevens wrote: > --- > v3 -> v4: > - Skip prefetch while invalidations are in progress Oof, nice catch. ... > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 9ac0a727015d..f6aaac729667 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -2758,6 +2758,13 @@ static void direct_pte_prefetch(struct kvm_vcpu *vcpu, u64 *sptep) > if (sp->role.level > PG_LEVEL_4K) > return; > > + /* > + * If addresses are being invalidated, skip prefetching to avoid > + * accidentally prefetching those addresses. > + */ > + if (unlikely(vcpu->kvm->mmu_notifier_count)) > + return; FNAME(pte_prefetch) needs the same check. Paolo, this brings up a good addition for the work to integrate the mmu notifier into the rest of KVM, e.g. for vmcs12 pages. Ideally, gfn_to_page_many_atomic() and __gfn_to_pfn_memslot() would WARN if mmu_notifier_count is non-zero, but that will fire all over the place until the nested code properly integrates the notifier. There are a few use cases where racing with the notifier is acceptable, e.g. reexecute_instruction(), but hopefully we can address those flows without things getting too ugly. > + > __direct_pte_prefetch(vcpu, sp, sptep); > }