All of lore.kernel.org
 help / color / mirror / Atom feed
From: Penny Zheng <Penny.Zheng@arm.com>
To: Julien Grall <julien@xen.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Wei Chen <Wei.Chen@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: RE: [PATCH v2 15/40] xen/arm: move MMU-specific memory management code to mm_mmu.c/mm_mmu.h
Date: Tue, 7 Feb 2023 03:59:34 +0000	[thread overview]
Message-ID: <AM0PR08MB4530246ADCB77E67CB5AB1B3F7DB9@AM0PR08MB4530.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <6aebebad-2b01-4bd6-8a2f-7be3591382d8@xen.org>

Hi,

> -----Original Message-----
> From: Julien Grall <julien@xen.org>
> Sent: Monday, February 6, 2023 5:30 AM
> To: Penny Zheng <Penny.Zheng@arm.com>; xen-devel@lists.xenproject.org
> Cc: Wei Chen <Wei.Chen@arm.com>; Stefano Stabellini
> <sstabellini@kernel.org>; Bertrand Marquis <Bertrand.Marquis@arm.com>;
> Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> Subject: Re: [PATCH v2 15/40] xen/arm: move MMU-specific memory
> management code to mm_mmu.c/mm_mmu.h
> 
> Hi,
> 
> On 13/01/2023 05:28, Penny Zheng wrote:
> > From: Wei Chen <wei.chen@arm.com>
> >
> > To make the code readable and maintainable, we move MMU-specific
> > memory management code from mm.c to mm_mmu.c and move MMU-
> specific
> > definitions from mm.h to mm_mmu.h.
> > Later we will create mm_mpu.h and mm_mpu.c for MPU-specific memory
> > management code.
> 
> This sentence implies there is no mm_mpu.{c, h} yet and this is not touched
> within this patch. However...
> 
> 
> > This will avoid lots of #ifdef in memory management code and header files.
> >
> > Signed-off-by: Wei Chen <wei.chen@arm.com>
> > Signed-off-by: Penny Zheng <penny.zheng@arm.com>
> > ---
> >   xen/arch/arm/Makefile             |    5 +
> >   xen/arch/arm/include/asm/mm.h     |   19 +-
> >   xen/arch/arm/include/asm/mm_mmu.h |   35 +
> >   xen/arch/arm/mm.c                 | 1352 +---------------------------
> >   xen/arch/arm/mm_mmu.c             | 1376
> +++++++++++++++++++++++++++++
> >   xen/arch/arm/mm_mpu.c             |   67 ++
> 
> ... It looks like they already exists and you are modifying them. That
> said, it would be better if this patch only contains code movement (IOW
> no MPU changes).
> 
> >   6 files changed, 1488 insertions(+), 1366 deletions(-)
> >   create mode 100644 xen/arch/arm/include/asm/mm_mmu.h
> >   create mode 100644 xen/arch/arm/mm_mmu.c
> 
> I don't particular like the naming. I think it would make more sense to
> introduce two directories: "mmu" and "mpu" which includes code specific
> to each flavor of Xen.
> 
[...]
> >
> > -
> > -/* Release all __init and __initdata ranges to be reused */
> > -void free_init_memory(void)
> 
> This function doesn't look specific to the MMU.
> 

Functions like, early_fdt_map[1] / setup_frametable_mappings[2] / free_init_memory [3] ...
they both share quite the same logic as MMU does in MPU system, the difference could only
be address translation regime. Still, in order to avoid putting too much #ifdef here and there,
I implement different MMU and MPU version of them.
 
Or I keep them in generic file here, then in future commits when we implement MPU version
of them(I list related commits below), I transfer them to MMU file there.

Wdyt?

[1] https://lists.xenproject.org/archives/html/xen-devel/2023-01/msg00774.html 
[2] https://lists.xenproject.org/archives/html/xen-devel/2023-01/msg00787.html 	
[3] https://lists.xenproject.org/archives/html/xen-devel/2023-01/msg00786.html 

> > -{
> > -    paddr_t pa = virt_to_maddr(__init_begin);
> > -    unsigned long len = __init_end - __init_begin;
> > -    uint32_t insn;
> > -    unsigned int i, nr = len / sizeof(insn);
> > -    uint32_t *p;
> > -    int rc;
> > -
> > -    rc = modify_xen_mappings((unsigned long)__init_begin,
> > -                             (unsigned long)__init_end, PAGE_HYPERVISOR_RW);
> > -    if ( rc )
> > -        panic("Unable to map RW the init section (rc = %d)\n", rc);
> > -
> > -    /*
> > -     * From now on, init will not be used for execution anymore,
> > -     * so nuke the instruction cache to remove entries related to init.
> > -     */
> > -    invalidate_icache_local();
> > -
> > -#ifdef CONFIG_ARM_32
> > -    /* udf instruction i.e (see A8.8.247 in ARM DDI 0406C.c) */
> > -    insn = 0xe7f000f0;
> > -#else
> > -    insn = AARCH64_BREAK_FAULT;
> > -#endif
> > -    p = (uint32_t *)__init_begin;
> > -    for ( i = 0; i < nr; i++ )
> > -        *(p + i) = insn;
> > -
> > -    rc = destroy_xen_mappings((unsigned long)__init_begin,
> > -                              (unsigned long)__init_end);
> > -    if ( rc )
> > -        panic("Unable to remove the init section (rc = %d)\n", rc);
> > -
> > -    init_domheap_pages(pa, pa + len);
> > -    printk("Freed %ldkB init memory.\n", (long)(__init_end-
> __init_begin)>>10);
> > -}
> > -
> 
> 
> [...]
> 
> > diff --git a/xen/arch/arm/mm_mpu.c b/xen/arch/arm/mm_mpu.c
> > index 43e9a1be4d..87a12042cc 100644
> > --- a/xen/arch/arm/mm_mpu.c
> > +++ b/xen/arch/arm/mm_mpu.c
> > @@ -20,8 +20,10 @@
> >    */
> >
> >   #include <xen/init.h>
> > +#include <xen/mm.h>
> >   #include <xen/page-size.h>
> >   #include <asm/arm64/mpu.h>
> > +#include <asm/page.h>
> 
> Regardless of what I wrote above, none of the code you add seems to
> require <asm/page.h>
> 
> >
> >   /* Xen MPU memory region mapping table. */
> >   pr_t __aligned(PAGE_SIZE) __section(".data.page_aligned")
> > @@ -38,6 +40,71 @@ uint64_t __ro_after_init next_transient_region_idx;
> >   /* Maximum number of supported MPU memory regions by the EL2 MPU.
> */
> >   uint64_t __ro_after_init max_xen_mpumap;
> >
> > +/* TODO: Implementation on the first usage */
> 
> It is not clear what you mean given there are some callers.
> 
> > +void dump_hyp_walk(vaddr_t addr)
> > +{
> 
> Please add ASSERT_UNREACHABLE() for any dummy helper you have
> introduced
> any plan to implement later. This will be helpful to track down any
> function you haven't implemented.
> 
> 
> > +}
> > +
> > +void * __init early_fdt_map(paddr_t fdt_paddr)
> > +{
> > +    return NULL;
> > +}
> > +
> > +void __init remove_early_mappings(void)
> > +{
> 
> Ditto
> 
> > +}
> > +
> > +int init_secondary_pagetables(int cpu)
> > +{
> > +    return -ENOSYS;
> > +}
> > +
> > +void mmu_init_secondary_cpu(void)
> > +{
> 
> Ditto. The name of the function is also a bit odd given this is an MPU
> specific file. This likely want to be renamed to mm_init_secondary_cpu().
> 
> > +}
> > +
> > +void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes)
> > +{
> > +    return NULL;
> > +}
> > +
> > +void *ioremap(paddr_t pa, size_t len)
> > +{
> > +    return NULL;
> > +}
> > +
> > +int map_pages_to_xen(unsigned long virt,
> > +                     mfn_t mfn,
> > +                     unsigned long nr_mfns,
> > +                     unsigned int flags)
> > +{
> > +    return -ENOSYS;
> > +}
> > +
> > +int destroy_xen_mappings(unsigned long s, unsigned long e)
> > +{
> > +    return -ENOSYS;
> > +}
> > +
> > +int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int
> flags)
> > +{
> > +    return -ENOSYS;
> > +}
> > +
> > +void free_init_memory(void)
> > +{
> 
> Ditto.
> 
> > +}
> > +
> > +int xenmem_add_to_physmap_one(
> > +    struct domain *d,
> > +    unsigned int space,
> > +    union add_to_physmap_extra extra,
> > +    unsigned long idx,
> > +    gfn_t gfn)
> > +{
> > +    return -ENOSYS;
> > +}
> > +
> >   /*
> >    * Local variables:
> >    * mode: C
> 
> --
> Julien Grall

  reply	other threads:[~2023-02-07  4:00 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13  5:28 [PATCH v2 00/41] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Penny Zheng
2023-01-13  5:28 ` [PATCH v2 01/40] xen/arm: remove xen_phys_start and xenheap_phys_end from config.h Penny Zheng
2023-01-13 10:06   ` Julien Grall
2023-01-13 10:39     ` Penny Zheng
2023-01-13  5:28 ` [PATCH v2 02/40] xen/arm: make ARM_EFI selectable for Arm64 Penny Zheng
2023-01-17 23:09   ` Julien Grall
2023-01-18  2:19     ` Wei Chen
2023-01-13  5:28 ` [PATCH v2 03/40] xen/arm: adjust Xen TLB helpers for Armv8-R64 PMSA Penny Zheng
2023-01-17 23:16   ` Julien Grall
2023-01-18  2:32     ` Wei Chen
2023-01-13  5:28 ` [PATCH v2 04/40] xen/arm: add an option to define Xen start address for Armv8-R Penny Zheng
2023-01-17 23:24   ` Julien Grall
2023-01-18  3:00     ` Wei Chen
2023-01-18  9:44       ` Julien Grall
2023-01-18 10:22         ` Wei Chen
2023-01-18 10:59           ` Julien Grall
2023-01-18 11:27             ` Wei Chen
2023-01-13  5:28 ` [PATCH v2 05/40] xen/arm64: prepare for moving MMU related code from head.S Penny Zheng
2023-01-17 23:37   ` Julien Grall
2023-01-18  3:09     ` Wei Chen
2023-01-18  9:50       ` Julien Grall
2023-01-18 10:24         ` Wei Chen
2023-01-13  5:28 ` [PATCH v2 06/40] xen/arm64: move MMU related code from head.S to head_mmu.S Penny Zheng
2023-01-13  5:28 ` [PATCH v2 07/40] xen/arm64: add .text.idmap for Xen identity map sections Penny Zheng
2023-01-17 23:46   ` Julien Grall
2023-01-18  2:18     ` Wei Chen
2023-01-18 10:55       ` Julien Grall
2023-01-18 11:40         ` Wei Chen
2023-01-13  5:28 ` [PATCH v2 08/40] xen/arm: use PA == VA for EARLY_UART_VIRTUAL_ADDRESS on Armv-8R Penny Zheng
2023-01-17 23:49   ` Julien Grall
2023-01-18  1:43     ` Wei Chen
2023-01-13  5:28 ` [PATCH v2 09/40] xen/arm: decouple copy_from_paddr with FIXMAP Penny Zheng
2023-01-13  5:28 ` [PATCH v2 10/40] xen/arm: split MMU and MPU config files from config.h Penny Zheng
2023-01-19 14:20   ` Julien Grall
2023-06-05  5:20     ` Penny Zheng
2023-01-13  5:28 ` [PATCH v2 11/40] xen/mpu: build up start-of-day Xen MPU memory region map Penny Zheng
2023-01-19 10:18   ` Ayan Kumar Halder
2023-01-29  6:47     ` Penny Zheng
2023-01-19 15:04   ` Julien Grall
2023-01-29  5:39     ` Penny Zheng
2023-01-29  7:37       ` Julien Grall
2023-01-30  5:45         ` Penny Zheng
2023-01-30  9:39           ` Julien Grall
2023-01-31  4:11             ` Penny Zheng
2023-01-31  9:27               ` Julien Grall
2023-02-01  5:39                 ` Penny Zheng
2023-02-01 18:56                   ` Julien Grall
2023-02-02 10:53                     ` Penny Zheng
2023-02-02 10:58                       ` Julien Grall
2023-02-02 11:30                         ` Penny Zheng
2023-01-13  5:28 ` [PATCH v2 12/40] xen/mpu: introduce helpers for MPU enablement Penny Zheng
2023-01-23 17:07   ` Ayan Kumar Halder
2023-01-24 18:54   ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 13/40] xen/mpu: introduce unified function setup_early_uart to map early UART Penny Zheng
2023-01-24 19:09   ` Julien Grall
2023-01-29  6:17     ` Penny Zheng
2023-01-29  7:43       ` Julien Grall
2023-01-30  6:24         ` Penny Zheng
2023-01-30 10:00           ` Julien Grall
2023-01-31  5:38             ` Penny Zheng
2023-01-31  9:41               ` Julien Grall
2023-02-01  5:36                 ` Penny Zheng
2023-02-01 19:26                   ` Julien Grall
2023-02-02  8:05                     ` Penny Zheng
2023-02-02 11:11                       ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 14/40] xen/arm64: head: Jump to the runtime mapping in enable_mm() Penny Zheng
2023-02-05 21:13   ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 15/40] xen/arm: move MMU-specific memory management code to mm_mmu.c/mm_mmu.h Penny Zheng
2023-02-05 21:30   ` Julien Grall
2023-02-07  3:59     ` Penny Zheng [this message]
2023-02-07  8:41       ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 16/40] xen/arm: introduce setup_mm_mappings Penny Zheng
2023-02-05 21:32   ` Julien Grall
2023-02-07  4:40     ` Penny Zheng
2023-01-13  5:28 ` [PATCH v2 17/40] xen/mpu: plump virt/maddr/mfn convertion in MPU system Penny Zheng
2023-02-05 21:36   ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 18/40] xen/mpu: introduce helper access_protection_region Penny Zheng
2023-01-24 19:20   ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 19/40] xen/mpu: populate a new region in Xen MPU mapping table Penny Zheng
2023-02-05 21:45   ` Julien Grall
2023-02-07  5:07     ` Penny Zheng
2023-01-13  5:28 ` [PATCH v2 20/40] xen/mpu: plump early_fdt_map in MPU systems Penny Zheng
2023-02-05 21:52   ` Julien Grall
2023-02-06 10:11   ` Julien Grall
2023-02-07  6:30     ` Penny Zheng
2023-02-07  8:47       ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 21/40] xen/arm: move MMU-specific setup_mm to setup_mmu.c Penny Zheng
2023-01-13  5:28 ` [PATCH v2 22/40] xen/mpu: implement MPU version of setup_mm in setup_mpu.c Penny Zheng
2023-01-13  5:28 ` [PATCH v2 23/40] xen/mpu: initialize frametable in MPU system Penny Zheng
2023-02-05 22:07   ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 24/40] xen/mpu: introduce "mpu,xxx-memory-section" Penny Zheng
2023-01-13  5:28 ` [PATCH v2 25/40] xen/mpu: map MPU guest memory section before static memory initialization Penny Zheng
2023-02-09 10:51   ` Julien Grall
2023-01-13  5:28 ` [PATCH v2 26/40] xen/mpu: destroy an existing entry in Xen MPU memory mapping table Penny Zheng
2023-02-09 10:57   ` Julien Grall
2023-01-13  5:29 ` [PATCH v2 27/40] xen/mpu: map device memory resource in MPU system Penny Zheng
2023-01-13  5:29 ` [PATCH v2 28/40] xen/mpu: map boot module section " Penny Zheng
2023-01-13  5:29 ` [PATCH v2 29/40] xen/mpu: introduce mpu_memory_section_contains for address range check Penny Zheng
2023-01-13  5:29 ` [PATCH v2 30/40] xen/mpu: disable VMAP sub-system for MPU systems Penny Zheng
2023-01-13  9:39   ` Jan Beulich
2023-01-13  5:29 ` [PATCH v2 31/40] xen/mpu: disable FIXMAP in MPU system Penny Zheng
2023-01-13  9:42   ` Jan Beulich
2023-01-13 10:10   ` Jan Beulich
2023-02-09 11:01     ` Julien Grall
2023-01-13  5:29 ` [PATCH v2 32/40] xen/mpu: implement MPU version of ioremap_xxx Penny Zheng
2023-01-13  9:49   ` Jan Beulich
2023-02-09 11:14   ` Julien Grall
2023-01-13  5:29 ` [PATCH v2 33/40] xen/arm: check mapping status and attributes for MPU copy_from_paddr Penny Zheng
2023-01-13  5:29 ` [PATCH v2 34/40] xen/mpu: free init memory in MPU system Penny Zheng
2023-02-09 11:27   ` Julien Grall
2023-01-13  5:29 ` [PATCH v2 35/40] xen/mpu: destroy boot modules and early FDT mapping " Penny Zheng
2023-01-13  5:29 ` [PATCH v2 36/40] xen/mpu: Use secure hypervisor timer for AArch64v8R Penny Zheng
2023-02-05 22:26   ` Julien Grall
2023-01-13  5:29 ` [PATCH v2 37/40] xen/mpu: move MMU specific P2M code to p2m_mmu.c Penny Zheng
2023-01-13  5:29 ` [PATCH v2 38/40] xen/mpu: implement setup_virt_paging for MPU system Penny Zheng
2023-01-13  5:29 ` [PATCH v2 39/40] xen/mpu: re-order xen_mpumap in arch_init_finialize Penny Zheng
2023-01-13  5:29 ` [PATCH v2 40/40] xen/mpu: add Kconfig option to enable Armv8-R AArch64 support Penny Zheng
2023-01-13  5:29 ` [PATCH] xen/mpu: make Xen boot to idle on MPU systems(DNM) Penny Zheng
2023-01-13  8:54 ` [PATCH v2 00/41] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Jan Beulich
2023-01-13  9:16   ` Julien Grall
2023-01-13  9:28     ` Jan Beulich
2023-01-24 19:31 ` Ayan Kumar Halder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM0PR08MB4530246ADCB77E67CB5AB1B3F7DB9@AM0PR08MB4530.eurprd08.prod.outlook.com \
    --to=penny.zheng@arm.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=Wei.Chen@arm.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.