[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen: arch_mfn_in_directmap: Reconciliate the name and the implementation


  • To: Julien Grall <julien@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 16 Dec 2021 17:11:11 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I92ZBA85YhkaIz1utKS+c48AvSwviGrRAUr86FhXOpg=; b=GK5xe2LKseTW18K7y9kUr90vQZ4hqiKrnxGb2RVqfswKx6wyfHCioqR8G6jZXqQPmdazuFL5LmRhuWE89OxdKNDFoJ0BX3au74otBBWpME9aVsRmSa+Mi5ltEwV5u+a3CMO2yzxGCeB4pEdpD1K4Mm83cmrbky4LTKIntxarg2w49jzfNfXy2XkxGKTD3tLABactwxhAPp203quT7erA2Pblut3UDmeNkneGf5cxoTYC4B3rbHrNKZ/bTYW5whS4oRERYJXtxziKXddMqUo9ibeQ3fp1INQ7EPTySgtIgxsYxy6Xz+Ul1RX71FIsvR4e5/GnXvGjAgswKG7BI4VwGQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dk0bkO0Cydb9fz8uym0hW7FkWyohMRGgUWmxL9DAFsEWGWfSxcmNSZIdRSL3KX40n9FA/Dt8/NYZmkgTnCd6UkVq++RohcSJirwyjR4zCOkZ05k2KWF8xB2Q/EOo8qnfC1f/560v47zV86bUCiHz88/VI0pcwIn+TGW5hviPGSRBuoUkgWOmLhKt576iT441p+DDJu7BX/ZSoXOnkr99t1gp/o8STPZ+ZyluApYAMzrFLrw9QaKV5l/xZhFVIyyzA6d6IJG3qWASfg+HXVhttrGduKW/yh/LDE4PEgtlMWK2Febc1Yg807qxlHDySFirS13G/wO4X31nx7yd2x5jLw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Julien Grall <jgrall@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 16 Dec 2021 16:11:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.12.2021 16:22, Julien Grall wrote:
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> The name of arch_mfn_in_directmap() suggests that it will check against
> that the passed MFN should be in the directmap.
> 
> However, the current callers are passing the next MFN and the
> implementation will return true for up to one MFN past the directmap.
> 
> It would be more meaningful to test the exact MFN rather than the
> next one. So rework the implementation and the caller to match the
> name.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
> 
> ---
> 
> Looking at the history, it looks like the check in init_node_heap()
> was <= and it was simply moved to a new helper without any adjustment
> as part of c6fdc9696a "boot allocator: use arch helper for virt_to_mfn
> on DIRECTMAP_VIRT region".

Really the original intention was to check the entire range; maybe it
would be better to express this again by ...

> --- a/xen/arch/x86/include/asm/mm.h
> +++ b/xen/arch/x86/include/asm/mm.h
> @@ -641,7 +641,7 @@ static inline bool arch_mfn_in_directmap(unsigned long 
> mfn)
>  {
>      unsigned long eva = min(DIRECTMAP_VIRT_END, HYPERVISOR_VIRT_END);
>  
> -    return mfn <= (virt_to_mfn(eva - 1) + 1);
> +    return mfn < (virt_to_mfn(eva - 1) + 1);
>  }

... this instead:

static inline bool arch_mfns_in_directmap(unsigned long mfn, unsigned long nr)
{
    unsigned long eva = min(DIRECTMAP_VIRT_END, HYPERVISOR_VIRT_END);

    return mfn + nr <= (virt_to_mfn(eva - 1) + 1);
}

This would allow an arch hook to also go beyond verifying just the last
MFN.

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.