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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13B19C05025 for ; Wed, 20 Sep 2023 21:04:45 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=ig6HgbWP; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RrWHv5Cp8z3cRg for ; Thu, 21 Sep 2023 07:04:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=ig6HgbWP; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--seanjc.bounces.google.com (client-ip=2607:f8b0:4864:20::649; helo=mail-pl1-x649.google.com; envelope-from=3nl4lzqykde89vr40tx55x2v.t532z4be66t-uvc2z9a9.5g2rs9.58x@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RrWGx3WzPz307h for ; Thu, 21 Sep 2023 07:03:53 +1000 (AEST) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1c4375c1406so1910555ad.1 for ; Wed, 20 Sep 2023 14:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695243830; x=1695848630; darn=lists.ozlabs.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=ig6HgbWPR5QsMZ3/GFuqUggEcB8oHt9PM/X5y3ybtNQkGkosRu0R+ToUoPhaoIEQk1 q59E+4h+RqhGjwoXebuWWjG5IuMt4tA2Y3U3wr9Z+jimNTOOjglWRI5CQZMeWmiviPnp UKiS0ZghzAdQHfzVpPPRuYNc0Gm4kYckd2I6vMqagGbHaX0menmD+OySTQn1M8c9fdPn iVmx0i9MA2LWbJ5XZ2dPYw1hnN0JOidS5JD3dkp0jreY7KtCiO1MHr0/THtebChynUcx sMBRU9IvuWjK9GCnwL4yrwkWQFjDzFbLXqv2zsrCEiN4eH5FkLy7dZr/47sYDAiirJ19 YzZg== 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=pd+Posh2mYB3SLbuvq9fVoUAy49DADdFkTQKXrHR7jsjQ80jnXjCB4zVanCDWDlzvD k8cGiIJB2mf/JylP+Ysymt1dlznZlglTS+D4dCJQI29CAbqJnkA0R8qHovahQtQIJgCY Qn60C32eqMobjvOR+7oDzRV4X5xWBC+G32gc+eez16IXFQJ4Q2wxkspFC9jb3KYGwiDB HImKLxIFejqdBn/+ME/kHaRGYCyWXWoO0t3Z8PMWTMAHYpG/mwLwiPYjWRg8XohzDRpL II4FTfkDl9q3uRwrhsjAi51/TTxlhKUbWOBNzxMJkRJNCJSWQVCh03JUKlLhBHHMjH6y JKqg== X-Gm-Message-State: AOJu0YzQO612/TOb5nxmI/WIfmlbkL6ojX+cdygloLAHYuddkwbNKwfC nKRHC/oKNRAmWy0qqmXaiPZ/d8TZLvA= X-Google-Smtp-Source: AGHT+IH5QBEwnaGAG6ouJVZQG2FiwG4z7ywKiDhgLSOOF+0VMXfLus6G3HR8pg7XpQjZrIgu3wnPZ1Tf/l8= 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 Content-Type: text/plain; charset="us-ascii" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, David Hildenbrand , Yu Zhang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chao Peng , linux-riscv@lists.infradead.org, Isaku Yamahata , Paul Moore , Marc Zyngier , Huacai Chen , James Morris , "Matthew Wilcox \(Oracle\)" , Wang , Fuad Tabba , Jarkko Sakkinen , "Serge E. Hallyn" , Maciej Szmigiero , Albert Ou , Vlastimil Babka , Michael Roth , Ackerley Tng , Paul Walmsley , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Isaku Yamahata , Quentin Perret , Liam Merwick , linux-mips@vger.kernel.org, Oliver Upton , linux-security-module@vger.kernel.org, Palmer Dabbelt , "Kirill A . Shutemov" , kvm-riscv@lists.infradead.org, Anup Patel , linux-fsdevel@vger.kernel.org, Paolo Bonzini , Andrew Morton , Vishal Annapurve , linuxppc-dev@lists.ozlabs.org, Xu Yilun , Anish Moorthy Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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.