Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2360672rdh; Tue, 26 Sep 2023 23:24:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEI3xa5gh9IhvmKHecmZgDLVt1Z70+pmg8TmOWG9NdP0eVJnRQiLRAXLz1K9pBYI+QkzzMr X-Received: by 2002:a05:6808:2a44:b0:3a8:8ea9:76f1 with SMTP id fa4-20020a0568082a4400b003a88ea976f1mr1354571oib.15.1695795862088; Tue, 26 Sep 2023 23:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695795862; cv=none; d=google.com; s=arc-20160816; b=AwGA5fDirjPuB1XUZghk7ouDGkZ3BUxhJ8cOnAkDFgofs/AxORuG6STo/xfh726TrV oCyIFHhm4v64VORET+wpm1w/0xNcQz3mkAf3IrN6QLvagwAJfRkbLK6K02nQDgQ9r1vX 454EOtOIagfaRqoAfPd1EMaNkFL00OvKyGXQOUkEspnuMQqHkaiV19OUOY9y8kttz0D6 4QN3ZU0cD77gizPZSv3mLUmjK3FPefd6vPHnHlt2ABJ5gWvB+kudhCoqo40ZQnjac7JL HXIMv46cTNbofKepzKQGoCSd1c/qQ6GPo5cxER9r9TlsG1ymKsfduIXulQHe80uRoie2 nTtA== 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=EJBmqOrPjvwuz3TdUb66dwChBKQwJC7E1LUoIPvUZTE=; fh=6tIgcrdU5AWeDZ1pzFQo9ftoyyjK82pQ36403WCtu0Q=; b=phTVndboNxrA2yOVpmOcxPFSS0iR6XA5jrbFNG8up4XyR6EuSVCCYQy9GVhnVp4gfw ahZXoD/NOQgyyQ0TFnfGKucMUJeje/pugkQu+ZaDWqBKWxdnBS7BjPjZ8gPfZYCjKwgX UrORYhZgqdtLetE6K2MANQxhZNie7EHLJZDscUomknGN2N2mdLgihl7YY7nr3MvX3m4H SaoyZmwpk4ZyTaOBYvhFxQkIwVV/vsyBMOUslcMYYFoIxf/pLQKCjU/PR4IRympxp2qG eHEC/WjuSntBCq+NkZbi9TQhpI1pV/pjrdsOhFax0EddyaAU7WxbJhbfeSQrhyha0LIc zI7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Rn0ykur+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id g125-20020a636b83000000b0056476f15584si15144797pgc.541.2023.09.26.23.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Rn0ykur+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id E66F98233662; Tue, 26 Sep 2023 22:23:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjI0FXV (ORCPT + 99 others); Wed, 27 Sep 2023 01:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjI0FWg (ORCPT ); Wed, 27 Sep 2023 01:22:36 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46345FD1; Tue, 26 Sep 2023 22:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695791982; x=1727327982; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=XWRHK3XHMCPUS7DjwBYEn6sN3WEf4Pd1a63R09LlTdM=; b=Rn0ykur+VAe+a1zUi7FEh4gFnxrFp628QOzK1Yld8tZhYzThnszJp/w+ Ywz2A0oi8KtkX4j/5zi+g3SG3duu/9UfmpT5BMmMUt7G6Fx2d3PeegCjk 8e/8j2kTtqx3d+tlzb2hvCy47F3H+b3hTj8/CWLUnzKfs4YHM6cCA0C6v TLqQH/aIfG191BNg9R+LE/gD9lYMoAH4vXBHB6uXNPkmhzW34XHyhmWBM eHkfrUGMlBsUoQFi4HPfYCjGistMDujHxTvc6e6zwGuSFzFgimPi38UZW +sEoJGpwLdsVYwLJcSCh9le0vKpCGCd5lEyeqJFTr0WfmNwHYazmgFNau w==; X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="381633578" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="381633578" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 22:19:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10845"; a="725676254" X-IronPort-AV: E=Sophos;i="6.03,179,1694761200"; d="scan'208";a="725676254" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.8.84]) ([10.238.8.84]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 22:19:32 -0700 Message-ID: <483f9e1e-7d01-5f06-3bfa-3788d2554724@linux.intel.com> Date: Wed, 27 Sep 2023 13:19:29 +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: 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, 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 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 22:23:32 -0700 (PDT) On 9/21/2023 5:03 AM, Sean Christopherson wrote: > 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. Seems this one is not included in the "KVM: guest_memfd fixes" patch series? https://lore.kernel.org/kvm/20230921203331.3746712-1-seanjc@google.com/