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

RE: [PATCH v5 3/5] xen/arm64: mm: Introduce helpers to prepare/enable/disable the identity mapping


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Sat, 28 Jan 2023 04:54:25 +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=3JT/aJUB8U4AgaGOam6ZEMPMEVnAM6/l9M9Q8RKHRzw=; b=B6is1xiqObPSjVd8MKUurnD9f/K5G+xic1ljINhDcws6Mo/oFPvgy/0wDMvD5PsRkg5Xt9niMv9U5Y93X6jJ02Y4S/xz9qrl55KEsFBI0aCHrIYoqdhPHgfVW0ICQDIc8lHIXpAxRfODvz5iVFY9ML09XeAy5jrovVHoyYfbmr4yVN85dCBs/Kc8y/Ga1kx4e7Tup5PsBLk8L3fPN20uRPPe3IagOxyCvwG3vBpQHgzC2THuNyvGo9z4yNmFPBWeHE70QmgPe0MmfUPtnDoPiMkccVv0ebRbCxET705p8mKQfwIHaERK9ayFxcYLyN/6phloca07wUOViEPDsAcCIw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QovIZRGzb8n3AVEeHbDozuQ5+S6KeS1spXUu+l19sBydMf+2LU3NUPn7WIZC53bJCmWUnLbN+vwJZFxOfQW8aTzYxfQtveHxv7H0lsjozp+yut7/1ghxBl6BFe4NiN2q6f+ODmvaeYoxO2Q0rMAgtovxDfw1OL8nWYuX7NoqUW9lA0EGQkrjmqjNCPPjXU7mZrF7S4Z8jeoYywMK8YJJ58S4wes94xAwGkXOb/dFMJ6lZgjtsI5ftrghMuzmGgtjeWhYtuHXVmCKpcjumzNSVgcfqJiDqkzc/NzQ8Vq9fOroPQLwqc4+B2eyHyndMPMpsUYSDKGl8GXrM5ZQnorYQw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Luca Fancellu <Luca.Fancellu@xxxxxxx>, "michal.orzel@xxxxxxx" <michal.orzel@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Sat, 28 Jan 2023 04:55:17 +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: AQHZMolY4mue8S6qKE2ltVytEV95o66zFE0A
  • Thread-topic: [PATCH v5 3/5] xen/arm64: mm: Introduce helpers to prepare/enable/disable the identity mapping

Hi Julien,

> -----Original Message-----
> Subject: [PATCH v5 3/5] xen/arm64: mm: Introduce helpers to
> prepare/enable/disable the identity mapping
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> In follow-up patches we will need to have part of Xen identity mapped in
> order to safely switch the TTBR.
> 
> On some platform, the identity mapping may have to start at 0. If we always
> keep the identity region mapped, NULL pointer dereference would lead to
> access to valid mapping.
> 
> It would be possible to relocate Xen to avoid clashing with address 0.
> However the identity mapping is only meant to be used in very limited
> places. Therefore it would be better to keep the identity region invalid
> for most of the time.
> 
> Two new external helpers are introduced:
>     - arch_setup_page_tables() will setup the page-tables so it is
>       easy to create the mapping afterwards.
>     - update_identity_mapping() will create/remove the identity mapping
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>

Reviewed-by: Henry Wang <Henry.Wang@xxxxxxx>
With some nits below that can definitely be fixed on commit.

Tested on FVP in Arm64 mode, so:
Tested-by: Henry Wang <Henry.Wang@xxxxxxx>

> +static void __init prepare_boot_identity_mapping(void)
> +{
> +    paddr_t id_addr = virt_to_maddr(_start);
> +    lpae_t pte;
> +    DECLARE_OFFSETS(id_offsets, id_addr);
> +
> +    /*
> +     * We will be re-using the boot ID tables. They may not have been
> +     * zeroed but they should be unlinked. So it is fine to use
> +     * clear_page().
> +     */
> +    clear_page(boot_first_id);
> +    clear_page(boot_second_id);
> +    clear_page(boot_third_id);
> +
> +    if ( id_offsets[0] != 0 )
> +        panic("Cannot handled ID mapping above 512GB\n");

Nit: s/handled/handle/

> +
> +static void __init prepare_runtime_identity_mapping(void)
> +{
> +    paddr_t id_addr = virt_to_maddr(_start);
> +    lpae_t pte;
> +    DECLARE_OFFSETS(id_offsets, id_addr);
> +
> +    if ( id_offsets[0] >= IDENTITY_MAPPING_AREA_NR_L0 )
> +        panic("Cannot handled ID mapping above 512GB\n");

Same here.

> +void arch_setup_page_tables(void);
> +
> +/*
> + * Enable/disable the identity mapping in the live page-tables (i.e.
> + * the one pointer by TTBR_EL2).

Nit: I might be wrong but I think s/pointer/pointed/.

> + *
> + * Note that nested a call (e.g. enable=true, enable=true) is not

Nit: s/nested/nesting/ or "a nested call"?

> + * supported.
> + */
> +void update_identity_mapping(bool enable);

Kind regards,
Henry




 


Rackspace

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