From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Date: Mon, 22 Feb 2021 16:24:51 +0000 Subject: Re: [PATCH v4 2/2] KVM: x86/mmu: Consider the hva in mmu_notifier retry Message-Id: List-Id: References: <20210222024522.1751719-1-stevensd@google.com> <20210222024522.1751719-3-stevensd@google.com> In-Reply-To: <20210222024522.1751719-3-stevensd@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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); > } 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=-8.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 0D3E5C433DB for ; Tue, 23 Feb 2021 14:49:14 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 5E23564E58 for ; Tue, 23 Feb 2021 14:49:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E23564E58 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CC0904B0D6; Tue, 23 Feb 2021 09:49:12 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 65-2QZ2CpUSr; Tue, 23 Feb 2021 09:49:11 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B72DB4B1D4; Tue, 23 Feb 2021 09:49:11 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B2AB54B159 for ; Mon, 22 Feb 2021 11:25:01 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kc5idE7keD8R for ; Mon, 22 Feb 2021 11:25:00 -0500 (EST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id A3AE14B14E for ; Mon, 22 Feb 2021 11:25:00 -0500 (EST) Received: by mail-pj1-f45.google.com with SMTP id b15so4371251pjb.0 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=VE9IQdFUvYe/JFTSNGJpbzHXOwvRGCDIuwNeLjoWEQY3944k1PqdIwdNebgDF34FIx k5b4AuCBH9uZ633dqQZnM1SApkdGNKK5u4xtdeAFtC0gul6yXYZ8b0WbOXJgwoTe/FFx /7jqpW6rCn0C9/ErCkn1RZkqpu/rfEfpyqTxSSqTqMXMebxeQw7EvRd1XmGflCIbiuDG 5sy5d197JFtes9fhJtnncP9aCI+HEZGEhzYMi1Kjs69mnVUMINONGWKL/bYGXROkSV/a LfecwdBZPWAqblVCMPNudTDiV+BU/vfq9XBHUFM8Tzn0n/ND9ENc8I7qtdBU7u/P8KE/ ZNpg== X-Gm-Message-State: AOAM531G4d2OxkcUCr2gkleZycJ3GjEcpzNQGs9AA7xL7bdwqcYD6Gvt Gm9WMd35qniiJqWDPCGOSKHoyA== 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 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-Disposition: inline In-Reply-To: <20210222024522.1751719-3-stevensd@google.com> X-Mailman-Approved-At: Tue, 23 Feb 2021 09:49:10 -0500 Cc: Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-mips@vger.kernel.org, Paul Mackerras , Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Janosch Frank , Marc Zyngier , Joerg Roedel , Huacai Chen , Christian Borntraeger , Aleksandar Markovic , kvm-ppc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jim Mattson , Cornelia Huck , linux-kernel@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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); > } _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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); > } 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=-8.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 029DDC433E0 for ; Mon, 22 Feb 2021 16:26:24 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2B4C64E2F for ; Mon, 22 Feb 2021 16:26:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2B4C64E2F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CiiH3AecB8Rw+BnT/NLSXG+lrdq3zimxlpyW6Ioas68=; b=NR5abQnXZWrbdZySlNSpen6Kv bH0t1AjiksEwNN2/OY1iBGxiwHCUXtnlx8iNzA8uC6W+F0O+uS4XzUPD6ZB+Jm+D2NJTYerKxIPt/ OjUVBtEyV4GJ/2qB5TRxHwUek1RNznSRrcg8hQet3S+yeaNWz8j2Dl6uKkrpHtX9bVFldUBDKhKaF lEaL8uRCocH2ZdUqmMsFO+0ENNLckoUHZ7JgwGW+yRf1lXyYiXtoodeDEbEX4sTtOEQo4EIaMDheg DWGbJs0lWeeQUOCy7nyRjKjskQe41KrdTv312feaZWrxVq5OjhyGF74vdU2iFsrqMHHxvwgJnh4Rg Qd4ZvbfaA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEE1E-0002Ex-Bc; Mon, 22 Feb 2021 16:25:08 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEE1A-0002Cm-4I for linux-arm-kernel@lists.infradead.org; Mon, 22 Feb 2021 16:25:05 +0000 Received: by mail-pj1-x102a.google.com with SMTP id o22so126554pjs.1 for ; Mon, 22 Feb 2021 08:25:01 -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=mfjqVhLokfjeXx4nRBeBkRkBcgOts4HrMuxp5shMW0zSJNb0eBMK4kWRVOf462kf2/ CiRMvrSHBBywyepIvtX6J245ky8aNUOoDibUsFan/zkFHBmUEJ69LFIn/iIyXblqiIRD qFXy4ruUvBFa37f8XJFC1yaIGwoUggJ+RGSTCq1WqT5UemcH4dvUB7sExBY14++oIlp9 pFwWC1rTgVxNjLdf7LCsKcYRk5jqPBTQNEtJK7RPnXTWNwc17tsR8LmkY1wKHfwIv27r jastvrtAvDOKKARr6+cdtfIrtPXHLu5LUT7OatRDp/FwoREoQkpN/4JbqH4X0/uv+vml o5Wg== X-Gm-Message-State: AOAM5309wJqt2JlIh1Wg8i4Z0xrDf9OqzD18hToK6U1lLkHTXO5qpdB7 OSJlyyOiJ5BciHJdYvbaCnGfRA== 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 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-Disposition: inline In-Reply-To: <20210222024522.1751719-3-stevensd@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210222_112504_255340_6AE7B2E1 X-CRM114-Status: GOOD ( 14.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-mips@vger.kernel.org, Paul Mackerras , Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Janosch Frank , Marc Zyngier , Joerg Roedel , Huacai Chen , Christian Borntraeger , Aleksandar Markovic , Julien Thierry , Suzuki K Poulose , kvm-ppc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jim Mattson , Cornelia Huck , linux-kernel@vger.kernel.org, James Morse , Paolo Bonzini , Vitaly Kuznetsov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel