From nobody Thu May 2 22:52:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1639668185; cv=none; d=zohomail.com; s=zohoarc; b=hgpkJdg5ClMD2f/TjXspsH3rcSNIJWXuzEZRYpARepZLd8WONeaAIrkQAaLwsoz4Iuxr7jU7b9Ey1O5GZ5FsHKDMiiwFDTQ8NZdFaKV6iHKqwxPuOSvo6VZSVrkXYaIOaO8HxFBn9wT4fpph1TOOoS29lgN9xFUpq0ExCqzgHn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639668185; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=JJmEh3TREYUIxqaWvyym6nwfJKMOMaOfV5meepyUfKU=; b=aVet2X0T868Iwxwp+BqCKGeleESBmNcfj90FEtpIWljJDP9SQwX2xRplFlhT/buZo2QgxY8oBOzqZjXVXOpRvw2MlEltyc11y26bb2wEUk8TdhxfSIuNS+uxNYcC+QJtYtTh1JZ9l4rGK1rKsu4AdLYblzfKWhXsa1avfqqUO1E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1639668185509217.31839594907342; Thu, 16 Dec 2021 07:23:05 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.248043.427797 (Exim 4.92) (envelope-from ) id 1mxsaf-0007jL-0F; Thu, 16 Dec 2021 15:22:41 +0000 Received: by outflank-mailman (output) from mailman id 248043.427797; Thu, 16 Dec 2021 15:22:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxsae-0007jE-T3; Thu, 16 Dec 2021 15:22:40 +0000 Received: by outflank-mailman (input) for mailman id 248043; Thu, 16 Dec 2021 15:22:39 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxsad-0007j8-R6 for xen-devel@lists.xenproject.org; Thu, 16 Dec 2021 15:22:39 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxsad-0001f3-MG; Thu, 16 Dec 2021 15:22:39 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mxsad-0002un-Dr; Thu, 16 Dec 2021 15:22:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From; bh=JJmEh3TREYUIxqaWvyym6nwfJKMOMaOfV5meepyUfKU=; b=4GzHnI htSodtFul/w7NZFYQK4tSDWZzKn5wxiruV+gi1JMCf8baDB/Yo58a9H7c/CzeMTT9jLEvsSlyK7nR NtbZTfGaCBYo96FeezhAJR5p4yf0rrEF9jowrc5LUXCDBAM9NxsbN+j6OtGs2EQ5M0agKPPhDjsrK QSqSfcbJHx8=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Stefano Stabellini Subject: [PATCH] xen: arch_mfn_in_directmap: Reconciliate the name and the implementation Date: Thu, 16 Dec 2021 15:22:20 +0000 Message-Id: <20211216152220.3317-1-julien@xen.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1639668187787100002 Content-Type: text/plain; charset="utf-8" From: Julien Grall 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 --- Looking at the history, it looks like the check in init_node_heap() was <=3D 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". --- xen/arch/x86/include/asm/mm.h | 2 +- xen/common/page_alloc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/mm.h b/xen/arch/x86/include/asm/mm.h index 5dbcee869624..a38e13e3c11e 100644 --- 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 =3D min(DIRECTMAP_VIRT_END, HYPERVISOR_VIRT_END); =20 - return mfn <=3D (virt_to_mfn(eva - 1) + 1); + return mfn < (virt_to_mfn(eva - 1) + 1); } =20 #endif /* __ASM_X86_MM_H__ */ diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 38eea879c04a..d4789f81cd31 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -588,7 +588,7 @@ static unsigned long init_node_heap(int node, unsigned = long mfn, needed =3D 0; } else if ( *use_tail && nr >=3D needed && - arch_mfn_in_directmap(mfn + nr) && + arch_mfn_in_directmap(mfn + nr - 1) && (!xenheap_bits || !((mfn + nr - 1) >> (xenheap_bits - PAGE_SHIFT))) ) { @@ -597,7 +597,7 @@ static unsigned long init_node_heap(int node, unsigned = long mfn, PAGE_SIZE - sizeof(**avail) * NR_ZONES; } else if ( nr >=3D needed && - arch_mfn_in_directmap(mfn + needed) && + arch_mfn_in_directmap(mfn + needed - 1) && (!xenheap_bits || !((mfn + needed - 1) >> (xenheap_bits - PAGE_SHIFT))) ) { --=20 2.32.0