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

RE: [PATCH] xen/arm64: Fix incorrect DIRECTMAP_SIZE calculation


  • To: Michal Orzel <michal.orzel@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Tue, 17 Jan 2023 03:10:28 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=HjaOFzc3csXxMX7AQyXBMtP1uvGNHik3RJzjrfKZYN8=; b=aK0d7zR8wtNR/izfsFTryNkbPRPnW3qsT49JiEexTQVnq15aQvlppN7EodE8Oc93QyZREOok7TdpAPffZRTCtbEUPsahejLGHoBVj2SqQCZVUXUf8xrxCJoInrfXZvbxlPzHI+RJSshistM+PS7MfwATBlUo+rC8badL5KNjtyktVEypTrlkQKg7LzsDbJUVZKvdLjO1H9JoYs80j24lH4dhLNHexApzStpU5R5ijAYGMXtBSlc7CII3uo6XMNnWK/bzRpLAeeqkrbYKwkY20FfdNpCfPLKNdxJiwfb0xAlTtnV0PU2qlATjP9yNGiCvlTcbjLdfkiMkTtOVihmdBg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bwLOViJ6u0CHzFWwXHrX2ZCznt3/zxeoHNP7cmI+cvb+1172IXpJkG5dzxkMsxYRgEVS/MSm42vVzeo4eyNZTRE4CCnagX5Kgr1MfUoZVdl959ZCxCVsUsktbqhAnCjbdTaT+gZzUubCl4lN4onha4+b1dGKITobfJWk9vc984NpC5heqLfSZPykgBZBEWlrpK0UUM5iOYgDz80kaoLBPPSuztkCTVI4bFO90ZLqiONGkk/pgTCdNiJgMtcSq0S479p/Q0PYEjvPfvqc6+vffdQQYJ6pGFzIBMIeUfy+PYNhHjPKawGKTJBxjE1CWntDs1wdIB+Rx8qO0A9wi+9E6w==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 17 Jan 2023 03:11:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZKbkuhF2CydVKlkSWMcq+jFNCca6h0FvQ
  • Thread-topic: [PATCH] xen/arm64: Fix incorrect DIRECTMAP_SIZE calculation

Hi Michal,

> -----Original Message-----
> Subject: [PATCH] xen/arm64: Fix incorrect DIRECTMAP_SIZE calculation
> 
> The direct mapped area occupies L0 slots from 256 to 265 (i.e. 10 slots),
> resulting in 5TB (512GB * 10) of virtual address space. However, due to
> incorrect slot subtraction (we take 9 slots into account) we set
> DIRECTMAP_SIZE to 4.5TB instead. Fix it.
> 
> Fixes: 5263507b1b4a ("xen: arm: Use a direct mapping of RAM on arm64")
> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
> ---
>  xen/arch/arm/include/asm/config.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/include/asm/config.h
> b/xen/arch/arm/include/asm/config.h
> index 0fefed1b8aa9..16213c8b677f 100644
> --- a/xen/arch/arm/include/asm/config.h
> +++ b/xen/arch/arm/include/asm/config.h
> @@ -157,7 +157,7 @@
>  #define FRAMETABLE_NR          (FRAMETABLE_SIZE / sizeof(*frame_table))
> 
>  #define DIRECTMAP_VIRT_START   SLOT0(256)
> -#define DIRECTMAP_SIZE         (SLOT0_ENTRY_SIZE * (265-256))
> +#define DIRECTMAP_SIZE         (SLOT0_ENTRY_SIZE * (266 - 256))

>From the commit message "L0 slots from 256 to 265 (i.e. 10 slots)", I think
the actual range is [256, 265] so probably using "(265 - 256 + 1)" here is a
bit better? It seems to me that the number 266 looks like a magic number
because 266 is not in the range. But this is my personal taste though and I
am open to discussion if you or maintainers have other opinions.

Maybe we can also putting a comment on top of the macro to explain this
calculation.

I did test this patch on FVP using XTP in both arm32 and arm64 execution
mode, and this patch is good, so:

Tested-by: Henry Wang <Henry.Wang@xxxxxxx>

Kind regards,
Henry



 


Rackspace

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