Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1710550rdb; Wed, 20 Sep 2023 18:15:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElWDl+sdYPEGpvSR6GJ/B15+rXld20C+quq6dqqUzXmQ3+vHW/IbNebCPkqmcQJ4ue0Iq5 X-Received: by 2002:a05:6808:13c1:b0:3ad:fd6a:e68c with SMTP id d1-20020a05680813c100b003adfd6ae68cmr1626270oiw.38.1695258946190; Wed, 20 Sep 2023 18:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695258946; cv=none; d=google.com; s=arc-20160816; b=JnjrAtwvTIMjRB9jrwwen1b9aqMpsWChScOTB64rJb9mzuGOkRdoLrbh6Zdl7sjP8u J8OqkYqxZyT18/+JzG/JFM45bttr8uCBtyYQ5wv6LBK8THpu1bluVdqObs4CmADsBB6/ XcC2IiNNw2R+C+msLGdXbONi5fiOdXnKIy5Az4QQOpN9U5OL/KBER6uR72dgkzvuM82H DVfxYi3pNbZRt/5OGwGAeJKAdJkwZxNn6C3Y4TEMAvJmmN628tJByu1NSd1UCzKKF3N4 72IxOAfMjzLAIxbaxx4WuVRi7LOdfyhzvj0bQ9yz9mZn+mk1AJN/kg7t0UUT9DrK5GEC wMLQ== 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=QFTXI1M20f8gmG6BvRAdcxEpoXePrbyr+CokqbvWBWc=; fh=3pYsw8iNZ4x7kDLFpA3j9F09TxC/WyOUd8LO/OKGIzI=; b=0U0CbrfISkNMTTIvWb9dmftuVMltHG2/K2T36t/rQfzMEvqnmDEIFfxk4cHGzTh6Iv fnrs15RPnUhOElyl1zh1CMr8iCN+SSZozOehwzM3KOj+ZsX3vvew1INedX3Di0SaSAfo YOb4dX6+Mqq3Y1v4mAojFB/aQ3UEuiRpJfjF1RkOu1cQW4s/oP16g7omrzIzkNhMf8BW bW84N/v4BqYvGuP/DyhPY30v5BxS0EMhT20nhtas8g457oBZLcbmh4kpxBd4mrHBnEsv oFI74kpTNK9ho8hwSxh4MMDkDqOonXo6OAcboFafToROSM2P3wBzPU7Zw/qBtTutX+g+ 2pxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YBB92SBC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id a21-20020a63e855000000b00578a7f5a0afsi281643pgk.357.2023.09.20.18.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 18:15:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YBB92SBC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 61918817C89C; Wed, 20 Sep 2023 14:04:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbjITVD7 (ORCPT + 99 others); Wed, 20 Sep 2023 17:03:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjITVD5 (ORCPT ); Wed, 20 Sep 2023 17:03:57 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A09CA for ; Wed, 20 Sep 2023 14:03:51 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1c4375c1406so1910565ad.1 for ; Wed, 20 Sep 2023 14:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695243830; x=1695848630; 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=QFTXI1M20f8gmG6BvRAdcxEpoXePrbyr+CokqbvWBWc=; b=YBB92SBCF7Hff5sSHvPsWLZsVpMrv+Nl0UIbQv7rB4s5KbvjkoryE7ANGFhAl3ZUOY XOz5HSz1JykM+i1Yb2lu7wu5YhqpmGp0qiwqGjag6g21TIuaOTtBANkCbe2wlhf62FxN 1lak6BOZ+i864pP48UrkEPAxbstc16yg2iUAL3kqaQojWszOZsLaQGyqW7Q17wFRA5pS YukXT15ZjEfn2V/sRN4udANdKQS7bHzeb1rCtJKrCEAXpTbsKVowFQcM2dYmMaK7zbY1 ARgNAbrAoaznbzr/fpH9ZnScVlSvAGQdDwVENeAYFHe1suNMj9gpIDcA1dEq4I4cKDvO t3zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695243830; x=1695848630; 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=QFTXI1M20f8gmG6BvRAdcxEpoXePrbyr+CokqbvWBWc=; b=T9b7el/BkLishvWdtFxCEPcmEwXc3xo+huNngQ/NfZR9hTZb2usvan0mOFaok9tmLH L9dzjog0smbhHxcBz0K/H29d/OPlvxbvKhFvBEQjeE1HqeekDi0yREkoqfuVo4CVFBzd WxqFR1qR+Yc7TfpWv+grTQVWE3cGY9yekzIDUEFTU0elxAuv2l6Ad3H063oPwSKdMSjO 7MDO+pSTU0xX4v35wcXr2UN0OCObz7tptIo9M83sHda75vDE8HD4A3Cwij1T4eq9diQN ljrJKfZ5bsa+SMM3r+7zplSMm7RxLbnLk61LyU2OMrFbbABJt6s+s9IiUlxRjfFZ1+6o KtbQ== X-Gm-Message-State: AOJu0YykSzKate6QrGtKieV7uTFSL0MfKkWMT0Abyf8bQXaoiUXSGjXB qSIQBB7yQTBlCYvjIXM59KCLtL7ijPw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:c407:b0:1c3:411c:9b7c with SMTP id k7-20020a170902c40700b001c3411c9b7cmr51568plk.13.1695243830643; Wed, 20 Sep 2023 14:03:50 -0700 (PDT) Date: Wed, 20 Sep 2023 14:03:49 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230914015531.1419405-1-seanjc@google.com> <20230914015531.1419405-12-seanjc@google.com> Message-ID: Subject: Re: [RFC PATCH v12 11/33] KVM: Introduce per-page memory attributes From: Sean Christopherson To: Binbin Wu Cc: 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, 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" , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , Yu Zhang , Isaku Yamahata , Xu Yilun , 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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 20 Sep 2023 14:04:11 -0700 (PDT) On Mon, Sep 18, 2023, Binbin Wu wrote: > > > On 9/14/2023 9:55 AM, Sean Christopherson wrote: > > From: Chao Peng > [...] > > +#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES > > +/* > > + * Returns true if _all_ gfns in the range [@start, @end) have attributes > > + * matching @attrs. > > + */ > > +bool kvm_range_has_memory_attributes(struct kvm *kvm, gfn_t start, gfn_t end, > > + unsigned long attrs) > > +{ > > + XA_STATE(xas, &kvm->mem_attr_array, start); > > + unsigned long index; > > + bool has_attrs; > > + void *entry; > > + > > + rcu_read_lock(); > > + > > + if (!attrs) { > > + has_attrs = !xas_find(&xas, end); > IIUIC, xas_find() is inclusive for "end", so here should be "end - 1" ? Yes, that does appear to be the case. Inclusive vs. exclusive on gfn ranges has is the bane of my existence.