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

Re: [v2 2/4] xen/arm32: head: Don't map too much in boot_third


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 4 Jul 2023 14:12:38 +0000
  • Accept-language: en-GB, 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=IEE8KzgJlSHeDg/R+ZsjJ/WFXESyQ2awb5p+KmS80/4=; b=mBBGZgz4fLXBCedR4hjQ0TRFMSvUDiVejSEbCh0nXDiMcgKEdq2Sx7dvU5vOmoGjuz+MPDbVE80eQRIl9r5WdnBDKmlhA/NM/kxT/3DI8pEw45xUOKGs9YSUCAApCLQEPGrWGwft0lNHpjycL2nZweowF+I5g54DS3OpeXdALWBruh7dUGPNqaOuc+bxc66YOmoZHv3LupdiGilNVD4cmbIMBjI5fr3nfBUBo9W9Mwh5F615BobJ4QPvG1VQvNzV5GA4hpgLI32uw9Soe2vz3MgxrXPwBnC0WtPBuPArYs5MctJStk9D+gwVyKQeeyX5lKYvXsu3YPgNJ3jV2X1cjA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QMXZxLY1tkKhEZ3mhtS12VF0i8KxFvQOfNNRclrNZFUNs/eScF2ppk3y86tVRKYoJq9enNEhYIu+ZAWQ/ytT5U91Nitm8K1d2cRAsY1J9C3lV/VzBj6bKDeiZdyJMx0qyeQrSqzq/A7ckBXFWRBBoX8fo6eejuag4oo1c2uxbG2sWDJdNvF3IlPuEudnv8WTZznAo6WsYOE+VdXY8o/IbTLuo3inOn+/rvPI5ORUh3DuRBn14zzgmnKioHO4u6f1JjIduI8/J35hS5wd/+tNpkQgG4CB6UemFdIYSrSIFQsGO9FJN2RatYOBMfxW84pe0e8B2g8+oWyhKnZPcOBNCw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Luca Fancellu <Luca.Fancellu@xxxxxxx>, "michal.orzel@xxxxxxx" <michal.orzel@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>
  • Delivery-date: Tue, 04 Jul 2023 14:13:41 +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: AQHZqsXz4VnOLQ2i/U6Z6/jlIuCSGK+prZQA
  • Thread-topic: [v2 2/4] xen/arm32: head: Don't map too much in boot_third

Hi Julien,

> On 29 Jun 2023, at 22:11, Julien Grall <julien@xxxxxxx> wrote:
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> At the moment, we are mapping the size of the reserved area for Xen
> (i.e. 2MB) even if the binary is smaller. We don't exactly know what's
> after Xen, so it is not a good idea to map more than necessary for a
> couple of reasons:
>    * We would need to use break-before-make if the extra PTE needs to
>      be updated to point to another region
>    * The extra area mapped may be mapped again by Xen with different
>      memory attribute. This would result to attribute mismatch.
> 
> Therefore, rework the logic in create_page_tables() to map only what's
> necessary. To simplify the logic, we also want to make sure _end
> is page-aligned. So align the symbol in the linker and add an assert
> to catch any change.

The last 2 sentences actually belongs to patch 1 and have been copied
here. Please remove them on commit as alignment of _end is not in
this patch.

> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
> 
With commit message fixed on commit:
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> 
>    Changes in v2:
>        - Fix typo
>        - Add Michal's reviewed-by tag
> ---
> xen/arch/arm/arm32/head.S | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
> index 1ad981b67460..5e3692eb3abf 100644
> --- a/xen/arch/arm/arm32/head.S
> +++ b/xen/arch/arm/arm32/head.S
> @@ -459,6 +459,19 @@ create_page_tables:
>         create_table_entry boot_pgtable, boot_second, r0, 1
>         create_table_entry boot_second, boot_third, r0, 2
> 
> +        /*
> +         * Find the size of Xen in pages and multiply by the size of a
> +         * PTE. This will then be compared in the mapping loop below.
> +         *
> +         * Note the multiplication is just to avoid using an extra
> +         * register/instruction per iteration.
> +         */
> +        mov_w r0, _start            /* r0 := vaddr(_start) */
> +        mov_w r1, _end              /* r1 := vaddr(_end) */
> +        sub   r0, r1, r0            /* r0 := effective size of Xen */
> +        lsr   r0, r0, #PAGE_SHIFT   /* r0 := Number of pages for Xen */
> +        lsl   r0, r0, #3            /* r0 := Number of pages * PTE size */
> +
>         /* Setup boot_third: */
>         adr_l r4, boot_third
> 
> @@ -473,7 +486,7 @@ create_page_tables:
> 1:      strd  r2, r3, [r4, r1]       /* Map vaddr(start) */
>         add   r2, r2, #PAGE_SIZE     /* Next page */
>         add   r1, r1, #8             /* Next slot */
> -        cmp   r1, #(XEN_PT_LPAE_ENTRIES<<3) /* 512*8-byte entries per page */
> +        cmp   r1, r0                 /* Loop until we map all of Xen */
>         blo   1b
> 
>         /*
> -- 
> 2.40.1
> 
> 




 


Rackspace

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