Received: by 2002:ac8:7144:0:b0:40f:fb00:664b with SMTP id h4csp1903845qtp; Mon, 18 Sep 2023 07:26:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWtkXDHVfB46NTGypRUx2647Z1gol27szU8MJVBTPZ7xudvbYnm874Z1ufQqtZCcG1SSqL X-Received: by 2002:a17:90a:3ea5:b0:276:6b9d:7503 with SMTP id k34-20020a17090a3ea500b002766b9d7503mr2105206pjc.28.1695047184925; Mon, 18 Sep 2023 07:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695047184; cv=none; d=google.com; s=arc-20160816; b=SgQp3YwGLZgKwcBjteyIO9JY30xYjiJ79DvrK2THDiQVeT7SIHbvr4OVkivAkfSz61 VXVQwj8gjqHpPLmFk1+pjip/ioV0RVqllzEp2x/jJSLBFnC2rwqqiOuFq8tlQQS7i8cg yjsZraxF1wyCEpmUtGO8M4fwwUa1FMBUHeS2f0tOIXxr5PhTHrUG+v0dAVO66UiGlnRv muFnIlkUuDSlJcigMUS4T8pYIjHW9hdkRGsd7bLWbb/+/6SFc6JBzXRALCtix0PFMXVn P0KORF7vSRiEgsJvtk7yFPqmORpHP52bS3CKSZM4rLyhwpEqy+O+Ric9iRV3piKmFH/w cVig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=Z5UFI3bFvQBLi9G8wcKHj2Lpnoh/6I1bDYyfY36jzOo=; fh=6tIgcrdU5AWeDZ1pzFQo9ftoyyjK82pQ36403WCtu0Q=; b=IcO1Qp7gs80Kzxepgx58dzgimaMLlWv99M+RxLYNFmPGM0mN+Pgyzrvh7QJZ0zoZS4 1f1WIwCrnSIW6CthqoJMkq9J8MJ9QR7iaTtEtEtQA+jPmPcOA2K6b5wWywNeOI4Urex1 I2uWhN+qeDt5W/fAy2q2P3FpDVSLlLEf61mqV0NJbqs2XsKxB5V6mwbAfwrp1nj9KVKw JPd4Sw6rO5XGcqnbkpS295KFKFBj95I9cQTHZuLQA2eutpGr4GVHGmo2vJNH0kE7nI1n r663B/UUPKxu2AQJTtV6fUHk4+RrNNjnZjX84ggV17ONSXarVS5k6HA+MQYPZPa2IXgX 0Y5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gb7QfdLj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f14-20020a17090a4a8e00b00274afd5346esi4887080pjh.151.2023.09.18.07.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 07:26:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gb7QfdLj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0D7AE8032024; Mon, 18 Sep 2023 00:54:42 -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 S240568AbjIRHyO (ORCPT + 99 others); Mon, 18 Sep 2023 03:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240512AbjIRHxi (ORCPT ); Mon, 18 Sep 2023 03:53:38 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC9DA129; Mon, 18 Sep 2023 00:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695023515; x=1726559515; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=F92rNU2upp1sAb9O/m30BxSQQfs05gdxlTOIwaluPho=; b=gb7QfdLj4L4ihjLLOdTuzP5NQV5P4uW9ry5TMuFR+qGTTL8tk9tg2hAS +FA9C1A+STzOT2Zfdx9AodyatFQNUuqo/cL4NoP87EGW4VHh+D6SqINnM bO8ldFVJOf+GwVG4b5rncPstb0wKDqmk0df9xBFm8LHQQv5XALa1B1Vs8 qYfKxpIWGVWh8cU9BHZa6VyvAeEA8NSlcPsPOi4mX/HxcjLTl9RgZeWGO +0fvkETy1/Jq0AubCahWBZJ1ZrGNFmeQMJY1KS0KiDUv2Phz+mna0bxLU ZFAA1BHEz22zpDPmaWKWsKV7gLZrJ0gcr7bW1dM6Ox1gKw45olY9+KT4l Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="382335539" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="382335539" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 00:51:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="811262156" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811262156" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.8.84]) ([10.238.8.84]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 00:51:45 -0700 Message-ID: Date: Mon, 18 Sep 2023 15:51:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC PATCH v12 11/33] KVM: Introduce per-page memory attributes To: Sean Christopherson 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" References: <20230914015531.1419405-1-seanjc@google.com> <20230914015531.1419405-12-seanjc@google.com> From: Binbin Wu In-Reply-To: <20230914015531.1419405-12-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 00:54:42 -0700 (PDT) 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" ? > + goto out; > + } > + > + has_attrs = true; > + for (index = start; index < end; index++) { > + do { > + entry = xas_next(&xas); > + } while (xas_retry(&xas, entry)); > + > + if (xas.xa_index != index || xa_to_value(entry) != attrs) { > + has_attrs = false; > + break; > + } > + } > + > +out: > + rcu_read_unlock(); > + return has_attrs; > +} > + > [...]