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

Re: [PATCH 1/5] arm/mpu: Implement setup_frametable_mappings for MPU systems


  • To: Hari Limaye <hari.limaye@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Thu, 21 Aug 2025 12:44:49 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=arm.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wVX7PgK0RRLc4eLIU8ow+X8k4uG2SZwxCU9rooQZTRg=; b=UryR/CUlSj/xR/vpcQlplPvKi2vmQlkWfrHvj16Goab2lK5TJwAu5xPblOzG4u5+aqfrtqu0spnGQ73YaCTbc4jTyqbAOdN6AipoGe/uUSXaYVKA5uXYWwaOUgYIGDxGnMbk2MxbmzmvQSAlrsbL7mLhFC6jcwfzgfb3G4611lIt/127xjM2NCCj5Ybe37I9QhZC8jCzO3CP0KPpvUGbvfeDWOFxNo9GIgcJdY70BpfAxOhVci5KxglUYaPxRy5SupajpPhzmlF3XwBebmiwwGxGpI538HUFHCoOvci+QNhQlUNvacs0gVBKOa1ko8hsWOUH9OyYj71bF0bxmk+5oQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kqsZD/cx8zq3AKD9p2ttV7vUNY+KwzDaIXl7vfat5NbcgI+z78lkva089dBbPmMm7qGhvvN8IbtpLAoMHBchz2lNuBK42Out0yatIykKldkKg9OZwBfVc7AFcOSO0YZp/98Iui9QDu/jKKPDIeTE1ghBiGb2wvnXb1Cc0fQqTZIVnrNreMntbftVpoKieYR7cTN6hGMbHMMEMq8BFcPa/tnjJSi94EOxmPiaoO5PYjgjVLMTdWODDSyOMAHr7EA1vJQqDgqsTro2NEJ+AL7DWB5GnsiePgPeXHWJ3ipNfJWlQKm/TpeRY2AOHe2gyoyuWsHASGi++lUy7Ou0nySxQg==
  • Cc: <luca.fancellu@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 21 Aug 2025 10:45:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 30/07/2025 10:45, Hari Limaye wrote:
> From: Luca Fancellu <luca.fancellu@xxxxxxx>
> 
> Implement the MPU variant of `setup_frametable_mappings`. This function
> will be called by `setup_mm` when an implementation for MPU systems is
> added in a follow up commit.
> 
> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> Signed-off-by: Hari Limaye <hari.limaye@xxxxxxx>
> ---
>  xen/arch/arm/mpu/mm.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/xen/arch/arm/mpu/mm.c b/xen/arch/arm/mpu/mm.c
> index c6891607ec..6a16fa348d 100644
> --- a/xen/arch/arm/mpu/mm.c
> +++ b/xen/arch/arm/mpu/mm.c
> @@ -168,6 +168,25 @@ int mpumap_contains_region(pr_t *table, uint8_t 
> nr_regions, paddr_t base,
>      return MPUMAP_REGION_NOTFOUND;
>  }
>  
> +/* Map a frame table to cover physical addresses ps through pe */
> +void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
> +{
> +    mfn_t base_mfn;
> +    unsigned long nr_pdxs = mfn_to_pdx(mfn_add(maddr_to_mfn(pe), -1)) -
> +                            mfn_to_pdx(maddr_to_mfn(ps)) + 1;
Don't you need to make sure that ps is rounded up to page size and e rounded 
down?

> +    unsigned long frametable_size = nr_pdxs * sizeof(struct page_info);
Why don't you need sanity checking with BUILD_BUG_ON to check frametable size?

> +
> +    frametable_base_pdx = paddr_to_pdx(ps);
> +    frametable_size = ROUNDUP(frametable_size, PAGE_SIZE);
> +
> +    base_mfn = alloc_boot_pages(frametable_size >> PAGE_SHIFT, 1);
> +    frame_table = (struct page_info *)mfn_to_virt(mfn_x(base_mfn));
> +
> +    memset(&frame_table[0], 0, nr_pdxs * sizeof(struct page_info));
> +    memset(&frame_table[nr_pdxs], -1,
> +           frametable_size - (nr_pdxs * sizeof(struct page_info)));
> +}
> +
>  /*
>   * Allocate an entry for a new EL2 MPU region in the bitmap xen_mpumap_mask.
>   * @param idx   Set to the index of the allocated EL2 MPU region on success.
Other than that:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal





 


Rackspace

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