Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1865245rdb; Thu, 21 Sep 2023 01:34:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLl88JrM3ny/XYP/RIW9v8rBMbmqYXCV5rHJewsonjFBPNamPcPfoj98BNgUMMNosMBCub X-Received: by 2002:a17:903:189:b0:1b8:6987:de84 with SMTP id z9-20020a170903018900b001b86987de84mr6558899plg.48.1695285275999; Thu, 21 Sep 2023 01:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695285275; cv=none; d=google.com; s=arc-20160816; b=phQfq4J1Un7HOg/WwCmUAS3BcRQw3Sqa2wzNxTqisduF29su/MdlJmMod4rNcB8uuf eaNXW5YeUsculf0N8HQ4CX0DdXm37oSRJk0mNBE7xmgA1K9kPGx/C9s9iQrWyuE6v8cP fMUNKWyhc4b/NtC5+MziaWfoDxjd8/bjemwCuaEXCjlBrcoCSjv48DYWEHWW7+iQE0pK xFdq+GJvl5TmtywZvkW8nwFoQbLJE1Al0j4oLwOYDIpDf4N4dSNv5LTjmHrA9yXgTZwT INxK0BfGdib+JBJ/maL7MLxZvlDQ/2pprwGCW+LvFb1TshnxwZ1M5PWD2pgbFR5ky5DI b0nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=0APReAt4bNnnd5kx+NahuCYj0tgbUgwxY6/xmv3q1x8=; fh=w51hLg2DMexND5MJ1pnR/yAQHK++aIx12kZWCEVmzno=; b=u45AFw3WH+6m8bnX1GqW5LlEYD5gIDVkmDuia3TXUs0IP3037pKCFw30KHpJWlpBjw pHfG9MSq8F2IrD9Am3DX93tAm2DmyeeE7ODjeiiFuhHZYWTy501Kv+jkVkTM6KrSh1nw vQr7kNqANwcuzaMFXtZiJ84VNFuC9AHjQ3ZTZTgxkynKr8uBRP2MKPhCNNk1cb4CLolk ExkJCKDNbtILCWnwmIwY1/UV8KYmTPGQe3BsuQxXdAFfDezVm2EXQoQb74aqdKnnslI1 4OEN+W08ChGPRJdAYXykQ4zkyeby0P2wVlmWVyS0aYvGSmCYWTc5cJOad8QO7jGETGww gogA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qYN6MLIf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id kz15-20020a170902f9cf00b001bb2d95f2a7si895720plb.267.2023.09.21.01.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 01:34:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qYN6MLIf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B73F98267526; Wed, 20 Sep 2023 06:56:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236595AbjITN4I (ORCPT + 99 others); Wed, 20 Sep 2023 09:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236533AbjITNzi (ORCPT ); Wed, 20 Sep 2023 09:55:38 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 769A1DD for ; Wed, 20 Sep 2023 06:55:07 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5924b2aac52so89054627b3.2 for ; Wed, 20 Sep 2023 06:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695218106; x=1695822906; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=0APReAt4bNnnd5kx+NahuCYj0tgbUgwxY6/xmv3q1x8=; b=qYN6MLIfTj4icmmBpIkd0WLhJxjSRWRnp5CVrZ5zO23Hc6SEWKaxnDv2NJItwfDuFQ 6RVvMGhZPLFVWocauiDyLryXn63S6KPTLdALA3Qsdgqj3uuPB/A2o/4ptf1HYp9bQI/0 1cYLmwlGz2SJqRrIPPncawpZ4aDzCTJ8sW2gL6tfKGnzilsZLa6El4ASlO1PaFkjNm/O bYywfPO/0UW/nevxIlFfp0aeaozdgulhoho9Sa50zXYSvg9W6zOTkgKB/8FODKp3Zw2Z dwA7/f8AInE7LDVv1jVJABSqsl1VCpa8fzDiXuUQzjW4V/dFydMGpeKFv2KS3ghLlvrS QzZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695218106; x=1695822906; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0APReAt4bNnnd5kx+NahuCYj0tgbUgwxY6/xmv3q1x8=; b=RzRaYkBXrAgiktUOfUVjR5GgoaSA9u+X2e7PKFLTzzlr68y2Ed66/y8e5va7Lz9SWS l084oW8BNNuRInOJHxbwNzd6bVQfwBIcSgZtopVfTMz6Z8Rie/yJ0UyOyktZeLpETGnt 7Aq46kHQ8Bswj0I2AO9LLOSVf26DC9lWVxtunbivWxUGq/wohSTguxoV0w8PBisD4EeD 1/OtjQC2vKq9SCmKNvEil+bKFlFf84fsageoXuI79CsVtcrKDEWEIrmXv271YWYaMgSu c8EenUjOQrr4wR6c9ZfhVlklneYAZptoNy+2w7fFw6SUcA5YdgFW6iQMyN6i3QYLvcQI 6Ekg== X-Gm-Message-State: AOJu0YxaIVLYJyWMk6xiKZR8PfC7S1k902soaume8umBj240inN+ue9x hCM6evsxh0M1ZIX80ThWsvKQmK0/Dn4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:ae57:0:b0:59b:ee27:bbe9 with SMTP id g23-20020a81ae57000000b0059bee27bbe9mr35901ywk.9.1695218106527; Wed, 20 Sep 2023 06:55:06 -0700 (PDT) Date: Wed, 20 Sep 2023 06:55:05 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230914015531.1419405-1-seanjc@google.com> <20230914015531.1419405-3-seanjc@google.com> Message-ID: Subject: Re: [RFC PATCH v12 02/33] KVM: Use gfn instead of hva for mmu_notifier_retry From: Sean Christopherson To: Xu Yilun Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , Yu Zhang , Isaku Yamahata , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 20 Sep 2023 06:56:06 -0700 (PDT) On Wed, Sep 20, 2023, Xu Yilun wrote: > On 2023-09-13 at 18:55:00 -0700, Sean Christopherson wrote: > > +void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t end) > > +{ > > + lockdep_assert_held_write(&kvm->mmu_lock); > > + > > + WARN_ON_ONCE(!kvm->mmu_invalidate_in_progress); > > + > > if (likely(kvm->mmu_invalidate_in_progress == 1)) { > > kvm->mmu_invalidate_range_start = start; > > kvm->mmu_invalidate_range_end = end; > > IIUC, Now we only add or override a part of the invalidate range in > these fields, IOW only the range in last slot is stored when we unlock. Ouch. Good catch! > That may break mmu_invalidate_retry_gfn() cause it can never know the > whole invalidate range. > > How about we extend the mmu_invalidate_range_start/end everytime so that > it records the whole invalidate range: > > if (kvm->mmu_invalidate_range_start == INVALID_GPA) { > kvm->mmu_invalidate_range_start = start; > kvm->mmu_invalidate_range_end = end; > } else { > kvm->mmu_invalidate_range_start = > min(kvm->mmu_invalidate_range_start, start); > kvm->mmu_invalidate_range_end = > max(kvm->mmu_invalidate_range_end, end); > } Yeah, that does seem to be the easiest solution. I'll post a fixup patch, unless you want the honors.