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

Re: [PATCH 6/7] xen/arm: mm: Add missing ISB in xen_pt_update()


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 4 Jul 2023 14:54:56 +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=uHPLYVWf3D08zYkdIrDgBPEq07v8K351XpAC2djDhZI=; b=LhC+7YqZ4hBUZ3+cNI6BjaBEpigVbX8FPjup+MBy2H7BsCXmw0gaAEYzbAbnkPSXrOBPjk8bJhrdNMs7e9c1x+Bvs+u95xkg4wIdgkj1AzGOGacwiycpHkGuXQZikFqTonwC85NCBPSDFTrLiSnqBWXxg9nwz/M0Zgd22FZ+FrWnPSm/frZoLNreVrvbGYlCQgz7P8ja5I54EfjCzXljrglfd1sfFdYocZmoPIj9Nvk5XdUXnExKPnH2SCHltwJ4L8tSOLIn7JyRgZ31YZhWfhxVIFjvYU68YmXfY8jwazf2vM3HmB6VpxjDo8kpuFeQtUWbKXB/g16vZEqrs5GrlA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BsdgMlRJ1B6LEewGfqLgbjXo9jwEEstaDw7DM+T9IrSo8YANPL6DaMp1ILLnmRrsDNaKhpqsK76Dv/eCdxtlaKBal5iFn7u6WeH9An5xNrcPKD51m7ShdF8OdkQ3eJ4IVJHmWDz/9RDVm8X/F/4riHoan4f9989vzSS4a9/4hm4eI9Nai6EGcBi+m7OKpYodjaXEdm4G3S+YXvAmBQZYPO3XA4kab0N9VynZd8id+G4hcNzLIlhcO73xQh/WoEn7Gca3i9s5p2re13SgGIjx6i87J94ehVK7FsAtW40LyAeRKupJ5aEDtC8vQxOE7sxQLFlIk7I6MMthku7brblU0w==
  • 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 04 Jul 2023 14:55:24 +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: AQHZos+28SuZIXCU302ZL5lufQv4QK+pyVIA
  • Thread-topic: [PATCH 6/7] xen/arm: mm: Add missing ISB in xen_pt_update()

Hi Julien,

> On 19 Jun 2023, at 19:01, Julien Grall <julien@xxxxxxx> wrote:
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> Per the Arm Arm, (Armv7 DDI406C.d A3.8.3 and Armv8 DDI 0487J.a B2.3.12):
> 
> "The DMB and DSB memory barriers affect reads and writes to the memory
> system generated by load/store instructions and data or unified cache
> maintenance operations being executed by the processor. Instruction
> fetches or accesses caused by a hardware translation table access are
> not explicit accesses."
> 
> Note that second sentence is not part of the newer Armv8 spec. But the
> interpretation is not much different.
> 
> The updated entry will not be used until xen_pt_update() completes.
> So rather than adding the ISB after write_pte() in create_xen_table()
> and xen_pt-update_entry(), add it in xen_pt_update().
> 
> Also document the reasoning of the deferral after each write_pte() calls.
> 
> Fixes: 07d11f63d03e ("xen/arm: mm: Avoid flushing the TLBs when mapping are 
> inserted")
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>

Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> xen/arch/arm/mm.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index e460249736c3..84e652799dd2 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -779,6 +779,11 @@ static int create_xen_table(lpae_t *entry)
>     pte = mfn_to_xen_entry(mfn, MT_NORMAL);
>     pte.pt.table = 1;
>     write_pte(entry, pte);
> +    /*
> +     * No ISB here. It is deferred to xen_pt_update() as the new table
> +     * will not be used for hardware translation table access as part of
> +     * the mapping update.
> +     */
> 
>     return 0;
> }
> @@ -1017,6 +1022,10 @@ static int xen_pt_update_entry(mfn_t root, unsigned 
> long virt,
>     }
> 
>     write_pte(entry, pte);
> +    /*
> +     * No ISB or TLB flush here. They are deferred to xen_pt_update()
> +     * as the entry will not be used as part of the mapping update.
> +     */
> 
>     rc = 0;
> 
> @@ -1196,6 +1205,9 @@ static int xen_pt_update(unsigned long virt,
>     /*
>      * The TLBs flush can be safely skipped when a mapping is inserted
>      * as we don't allow mapping replacement (see xen_pt_check_entry()).
> +     * Although we still need an ISB to ensure any DSB in
> +     * write_pte() will complete because the mapping may be used soon
> +     * after.
>      *
>      * For all the other cases, the TLBs will be flushed unconditionally
>      * even if the mapping has failed. This is because we may have
> @@ -1204,6 +1216,8 @@ static int xen_pt_update(unsigned long virt,
>      */
>     if ( !((flags & _PAGE_PRESENT) && !mfn_eq(mfn, INVALID_MFN)) )
>         flush_xen_tlb_range_va(virt, PAGE_SIZE * nr_mfns);
> +    else
> +        isb();
> 
>     spin_unlock(&xen_pt_lock);
> 
> -- 
> 2.40.1
> 




 


Rackspace

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