Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp412489rwb; Tue, 6 Dec 2022 23:35:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf78TP9BByY7Iwv6GFCKzOnahVxuxik8VubuxqqAqUB5l+8p9ToMm1r1FkDp9OWB0tOF1Ctz X-Received: by 2002:a17:906:3711:b0:7c1:d4b:7541 with SMTP id d17-20020a170906371100b007c10d4b7541mr4576294ejc.614.1670398549928; Tue, 06 Dec 2022 23:35:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670398549; cv=none; d=google.com; s=arc-20160816; b=ILrsICNf4mobySeH6Z70vn9bMSqFtHMZYQN5aHIKBaBqdAvcBIUVUhAVqQS3YLrqjG izwzOIy4LFwEmV8+m3HA0qO1iSzJrG8KIs+nNq/SNffdd6lMmitVF/2P1kgwfe+vMNH8 qYM9GxGBoFw5Zi8HyNXunOUgfy5GmZiWkW2puanfbPBcrQHIL/Y0BVv3X6mq/G1LTbOS fPSEBHMoD+1rAUPa53+pG7zCbV6TNWHOi2d0YoUmp89HuU4mi41eEhiFmWMnFSb+aWMp U7gEP4lnU9pPxtrGfHymcjJkHDaAEUxjb55HTUsE2ensaXFvOtFEEdC6RRMRKVadY7lJ G/1g== 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=C15cHp35UgTVcGwyWVF0FgqoGcE+bZVU/5tK1HiVhGg=; b=Vx23riYUoGE3jdTwxfEFxlVjf22gbyKEVABchRYBM+lNt2AG6kGX+lGJXchZHNRfj8 3ziBd2zodQYSGLO7Gwcihyd+vRVqTwwopxHc9SPzDNExEK3qgSOTDpQZ8A/zRYVk6GZB sdjyG4DcVyZHz00AFnpZJ0VYRBrwq9ndSO2x3A6rExhhxS1zIshY1fEfqMmoD1bDz4gy naXyZMTAmQ7epsx4uka3kJL3VzY9jUG1OsSpoQdZunkyRKvdevo6ZEkH5OCWoJj5HICN GoajZ9fMKmtZsoozMm6sMETj4yyoWrotnSm8AcaAICoA7ou8/GL7KrMLZr77w9Fzcc1U oP6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="CKqZ/l9P"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a170906340d00b00782161b3422si12400953ejb.914.2022.12.06.23.35.31; Tue, 06 Dec 2022 23:35:49 -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=@gmail.com header.s=20210112 header.b="CKqZ/l9P"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbiLGGeT (ORCPT + 76 others); Wed, 7 Dec 2022 01:34:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiLGGeP (ORCPT ); Wed, 7 Dec 2022 01:34:15 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA34B532F9; Tue, 6 Dec 2022 22:34:14 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id b13-20020a17090a5a0d00b0021906102d05so598173pjd.5; Tue, 06 Dec 2022 22:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=C15cHp35UgTVcGwyWVF0FgqoGcE+bZVU/5tK1HiVhGg=; b=CKqZ/l9PnwBZEtXNtp4aPBttpJeA89ZaQxsLN+jKw3eUVeg9N70IqMgdpBhfmoMdRN wnNcjMkoLzHDq6uSVjjvzsYnerZjG1HIAwRJ1o5QS5Yp8oNstErg28aAus8PdaoLeqx3 f2++jCdgHb8lDQ6ETyzyDMSqpkHcnxdDTU7zRBcFo3QBH9uNzewTIfvJ1efH8a1UHYv+ dz6o9xbAOwTWr7xaQjDIg+nKseYPUY71PlOmzpnNJTkqlzgQvjmD1yQTL6sJfRdqQoUC XKpDVo69w4cJKZZVhcBHWOWsfC+8Xh7NT3VFznBfTVfB1ab0ptONygi3M5nMJitgBbY6 fyNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=C15cHp35UgTVcGwyWVF0FgqoGcE+bZVU/5tK1HiVhGg=; b=2Ek8fGIey6iriKjVEhl0pi73rfM2kp/BVpFOJbNUiFJF6OwsXAyLIusb5D0TO9CsTR q97ZGmrrAP85ulnVE0XL8G+7vyPDMCq8lggDHkYKQfeciE+QivCJuk2RbjDU9ZNn+eKA hp5zPByqrCxrApDEs0T0AibL9eWpUgr7roF+9KvxN6Be5TOr2lHOxhPRSmAmOAZJQfFV mCR3Wt1YVPttwVQJklgcf5npVxSx2AeGQL69dIPgy6/MiyyKnyJqjfX+TxHjiRXr0JuJ P+PRrGhNtW+/eTCEAcE9+BARt+ZxeheocYty391Y4aD912PYuodInZ0Vx0lCgZYMxIuI FElg== X-Gm-Message-State: ANoB5pll+U0ThoCRxfPTtUeuDt2Y9Oq4ZAuCoRTzHDFegSNEWJLkqGyT LRNttswfmWNzBU1RqEdyiJ4= X-Received: by 2002:a17:90a:9313:b0:213:2168:1c78 with SMTP id p19-20020a17090a931300b0021321681c78mr99342910pjo.72.1670394853895; Tue, 06 Dec 2022 22:34:13 -0800 (PST) Received: from localhost ([192.55.54.55]) by smtp.gmail.com with ESMTPSA id x6-20020a623106000000b005745eb7eccasm12686643pfx.112.2022.12.06.22.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 22:34:12 -0800 (PST) Date: Tue, 6 Dec 2022 22:34:11 -0800 From: Isaku Yamahata To: Chao Peng Cc: Fuad Tabba , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Arnd Bergmann , Naoya Horiguchi , Miaohe Lin , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, wei.w.wang@intel.com, isaku.yamahata@gmail.com Subject: Re: [PATCH v10 5/9] KVM: Use gfn instead of hva for mmu_notifier_retry Message-ID: <20221207063411.GB3632095@ls.amr.corp.intel.com> References: <20221202061347.1070246-1-chao.p.peng@linux.intel.com> <20221202061347.1070246-6-chao.p.peng@linux.intel.com> <20221206115623.GB1216605@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221206115623.GB1216605@chaop.bj.intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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, Dec 06, 2022 at 07:56:23PM +0800, Chao Peng wrote: > > > - if (unlikely(kvm->mmu_invalidate_in_progress) && > > > - hva >= kvm->mmu_invalidate_range_start && > > > - hva < kvm->mmu_invalidate_range_end) > > > - return 1; > > > + if (unlikely(kvm->mmu_invalidate_in_progress)) { > > > + /* > > > + * Dropping mmu_lock after bumping mmu_invalidate_in_progress > > > + * but before updating the range is a KVM bug. > > > + */ > > > + if (WARN_ON_ONCE(kvm->mmu_invalidate_range_start == INVALID_GPA || > > > + kvm->mmu_invalidate_range_end == INVALID_GPA)) > > > > INVALID_GPA is an x86-specific define in > > arch/x86/include/asm/kvm_host.h, so this doesn't build on other > > architectures. The obvious fix is to move it to > > include/linux/kvm_host.h. > > Hmm, INVALID_GPA is defined as ZERO for x86, not 100% confident this is > correct choice for other architectures, but after search it has not been > used for other architectures, so should be safe to make it common. INVALID_GPA is defined as all bit 1. Please notice "~" (tilde). #define INVALID_GPA (~(gpa_t)0) -- Isaku Yamahata