diff mbox series

[v5,3/3] xen/arm32: mpu: Stubs to build MPU for arm32

Message ID 20250407184443.1790995-4-ayan.kumar.halder@amd.com (mailing list archive)
State Superseded
Headers show
Series Enable early bootup of Armv8-R AArch32 systems | expand

Commit Message

Ayan Kumar Halder April 7, 2025, 6:44 p.m. UTC
Add stubs to enable compilation

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
---
Changes from :-

v1, v2 -
1. New patch introduced in v3.
2. Should be applied on top of
https://patchwork.kernel.org/project/xen-devel/cover/20250316192445.2376484-1-luca.fancellu@arm.com/

v3 -
1. Add stubs for map_domain_page() and similar functions.

2. 'BUG_ON("unimplemented")' is kept in all the stubs.

v4 - 
1. is_xen_heap_mfn() macros are defined across mpu/mm.h (ARM32 specific)
, mmu/mm.h (ARM32 specific) and asm/mm.h (ARM64 specific)

2. s/(void*)0/NULL

 xen/arch/arm/arm32/mpu/Makefile   |  2 ++
 xen/arch/arm/arm32/mpu/p2m.c      | 18 ++++++++++++++
 xen/arch/arm/arm32/mpu/smpboot.c  | 23 +++++++++++++++++
 xen/arch/arm/include/asm/mm.h     |  9 +------
 xen/arch/arm/include/asm/mmu/mm.h |  9 +++++++
 xen/arch/arm/include/asm/mpu/mm.h |  5 ++++
 xen/arch/arm/mpu/Makefile         |  1 +
 xen/arch/arm/mpu/domain_page.c    | 41 +++++++++++++++++++++++++++++++
 8 files changed, 100 insertions(+), 8 deletions(-)
 create mode 100644 xen/arch/arm/arm32/mpu/p2m.c
 create mode 100644 xen/arch/arm/arm32/mpu/smpboot.c
 create mode 100644 xen/arch/arm/mpu/domain_page.c

Comments

Luca Fancellu April 8, 2025, 9:23 a.m. UTC | #1
Hi Ayan,

> On 7 Apr 2025, at 19:44, Ayan Kumar Halder <ayan.kumar.halder@amd.com> wrote:
> 
> Add stubs to enable compilation
> 
> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
> ---
> Changes from :-
> 
> v1, v2 -
> 1. New patch introduced in v3.
> 2. Should be applied on top of
> https://patchwork.kernel.org/project/xen-devel/cover/20250316192445.2376484-1-luca.fancellu@arm.com/
> 
> v3 -
> 1. Add stubs for map_domain_page() and similar functions.
> 
> 2. 'BUG_ON("unimplemented")' is kept in all the stubs.
> 
> v4 - 
> 1. is_xen_heap_mfn() macros are defined across mpu/mm.h (ARM32 specific)
> , mmu/mm.h (ARM32 specific) and asm/mm.h (ARM64 specific)
> 
> 2. s/(void*)0/NULL
> 
> xen/arch/arm/arm32/mpu/Makefile   |  2 ++
> xen/arch/arm/arm32/mpu/p2m.c      | 18 ++++++++++++++
> xen/arch/arm/arm32/mpu/smpboot.c  | 23 +++++++++++++++++
> xen/arch/arm/include/asm/mm.h     |  9 +------
> xen/arch/arm/include/asm/mmu/mm.h |  9 +++++++
> xen/arch/arm/include/asm/mpu/mm.h |  5 ++++
> xen/arch/arm/mpu/Makefile         |  1 +
> xen/arch/arm/mpu/domain_page.c    | 41 +++++++++++++++++++++++++++++++
> 8 files changed, 100 insertions(+), 8 deletions(-)
> create mode 100644 xen/arch/arm/arm32/mpu/p2m.c
> create mode 100644 xen/arch/arm/arm32/mpu/smpboot.c
> create mode 100644 xen/arch/arm/mpu/domain_page.c
> 
> diff --git a/xen/arch/arm/arm32/mpu/Makefile b/xen/arch/arm/arm32/mpu/Makefile
> index 3340058c08..38797f28af 100644
> --- a/xen/arch/arm/arm32/mpu/Makefile
> +++ b/xen/arch/arm/arm32/mpu/Makefile
> @@ -1 +1,3 @@
> obj-y += head.o
> +obj-y += smpboot.o
> +obj-y += p2m.o
> diff --git a/xen/arch/arm/arm32/mpu/p2m.c b/xen/arch/arm/arm32/mpu/p2m.c
> new file mode 100644
> index 0000000000..df8de5c7d8
> --- /dev/null
> +++ b/xen/arch/arm/arm32/mpu/p2m.c
> @@ -0,0 +1,18 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +

I would add:
#include <xen/bug.h>
for BUG()

> +#include <xen/init.h>
> +#include <asm/p2m.h>
> +
> +void __init setup_virt_paging(void)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/arm/arm32/mpu/smpboot.c b/xen/arch/arm/arm32/mpu/smpboot.c
> new file mode 100644
> index 0000000000..3f3e54294e
> --- /dev/null
> +++ b/xen/arch/arm/arm32/mpu/smpboot.c
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +

I would add:
#include <xen/bug.h>
for BUG()

#include <xen/errno.h>
for EINVAL

#include <xen/stdbool.h>
for bool

> +#include <xen/mm.h>
> +
> +int prepare_secondary_mm(int cpu)
> +{
> +    BUG_ON("unimplemented");
> +    return -EINVAL;
> +}
> +
> +void update_boot_mapping(bool enable)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
> index fbffaccef4..5b67c0f8bb 100644
> --- a/xen/arch/arm/include/asm/mm.h
> +++ b/xen/arch/arm/include/asm/mm.h
> @@ -170,14 +170,7 @@ struct page_info
> #define _PGC_need_scrub   _PGC_allocated
> #define PGC_need_scrub    PGC_allocated
> 
> -#ifdef CONFIG_ARM_32
> -#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
> -#define is_xen_heap_mfn(mfn) ({                                 \
> -    unsigned long mfn_ = mfn_x(mfn);                            \
> -    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
> -     mfn_ < mfn_x(directmap_mfn_end));                          \
> -})
> -#else
> +#ifdef CONFIG_ARM_64
> #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap)
> #define is_xen_heap_mfn(mfn) \
>     (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
> diff --git a/xen/arch/arm/include/asm/mmu/mm.h b/xen/arch/arm/include/asm/mmu/mm.h
> index caba987edc..9b98d12b07 100644
> --- a/xen/arch/arm/include/asm/mmu/mm.h
> +++ b/xen/arch/arm/include/asm/mmu/mm.h
> @@ -21,6 +21,15 @@ extern unsigned long directmap_base_pdx;
> 
> #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
> 
> +#ifdef CONFIG_ARM_32
> +#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
> +#define is_xen_heap_mfn(mfn) ({                                 \
> +    unsigned long mfn_ = mfn_x(mfn);                            \
> +    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
> +     mfn_ < mfn_x(directmap_mfn_end));                          \
> +})
> +#endif
> +
> #define virt_to_maddr(va) ({                                                   \
>     vaddr_t va_ = (vaddr_t)(va);                                               \
>     (paddr_t)((va_to_par(va_) & PADDR_MASK & PAGE_MASK) | (va_ & ~PAGE_MASK)); \
> diff --git a/xen/arch/arm/include/asm/mpu/mm.h b/xen/arch/arm/include/asm/mpu/mm.h
> index 86f33d9836..bfd840fa5d 100644
> --- a/xen/arch/arm/include/asm/mpu/mm.h
> +++ b/xen/arch/arm/include/asm/mpu/mm.h
> @@ -13,6 +13,11 @@ extern struct page_info *frame_table;
> 
> #define virt_to_maddr(va) ((paddr_t)((vaddr_t)(va) & PADDR_MASK))
> 
> +#ifdef CONFIG_ARM_32
> +#define is_xen_heap_page(page) ({ BUG_ON("unimplemented"); false; })
> +#define is_xen_heap_mfn(mfn) ({ BUG_ON("unimplemented"); false; })
> +#endif
> +
> /* On MPU systems there is no translation, ma == va. */
> static inline void *maddr_to_virt(paddr_t ma)
> {
> diff --git a/xen/arch/arm/mpu/Makefile b/xen/arch/arm/mpu/Makefile
> index 21bbc517b5..ff221011d5 100644
> --- a/xen/arch/arm/mpu/Makefile
> +++ b/xen/arch/arm/mpu/Makefile
> @@ -2,3 +2,4 @@ obj-y += mm.o
> obj-y += p2m.o
> obj-y += setup.init.o
> obj-y += vmap.o
> +obj-$(CONFIG_ARM_32) += domain_page.o
> diff --git a/xen/arch/arm/mpu/domain_page.c b/xen/arch/arm/mpu/domain_page.c
> new file mode 100644
> index 0000000000..8859b24e04
> --- /dev/null
> +++ b/xen/arch/arm/mpu/domain_page.c
> @@ -0,0 +1,41 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +#include <xen/domain_page.h>

I would add:

#include <xen/bug.h>
for BUG()

#include <xen/mm-frame.h>
for mfn_t and INVALID_MFN

#include <xen/types.h>
for NULL


> +
> +void *map_domain_page_global(mfn_t mfn)
> +{
> +    BUG_ON("unimplemented");
> +    return NULL;
> +}
> +
> +/* Map a page of domheap memory */
> +void *map_domain_page(mfn_t mfn)
> +{
> +    BUG_ON("unimplemented");
> +    return NULL;
> +}
> +
> +/* Release a mapping taken with map_domain_page() */
> +void unmap_domain_page(const void *ptr)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +mfn_t domain_page_map_to_mfn(const void *ptr)
> +{
> +    BUG_ON("unimplemented");
> +    return INVALID_MFN;
> +}
> +
> +void unmap_domain_page_global(const void *va)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> -- 
> 2.25.1

with the above addressed, at least for me it looks good!

Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>

Cheers,
Luca
Orzel, Michal April 8, 2025, 9:54 a.m. UTC | #2
On 07/04/2025 20:44, Ayan Kumar Halder wrote:
> Add stubs to enable compilation
NIT: missing dot at the end of sentence.

> 
> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
> ---
> Changes from :-
> 
> v1, v2 -
> 1. New patch introduced in v3.
> 2. Should be applied on top of
> https://patchwork.kernel.org/project/xen-devel/cover/20250316192445.2376484-1-luca.fancellu@arm.com/
> 
> v3 -
> 1. Add stubs for map_domain_page() and similar functions.
> 
> 2. 'BUG_ON("unimplemented")' is kept in all the stubs.
> 
> v4 - 
> 1. is_xen_heap_mfn() macros are defined across mpu/mm.h (ARM32 specific)
> , mmu/mm.h (ARM32 specific) and asm/mm.h (ARM64 specific)
> 
> 2. s/(void*)0/NULL
> 
>  xen/arch/arm/arm32/mpu/Makefile   |  2 ++
>  xen/arch/arm/arm32/mpu/p2m.c      | 18 ++++++++++++++
>  xen/arch/arm/arm32/mpu/smpboot.c  | 23 +++++++++++++++++
>  xen/arch/arm/include/asm/mm.h     |  9 +------
>  xen/arch/arm/include/asm/mmu/mm.h |  9 +++++++
>  xen/arch/arm/include/asm/mpu/mm.h |  5 ++++
>  xen/arch/arm/mpu/Makefile         |  1 +
>  xen/arch/arm/mpu/domain_page.c    | 41 +++++++++++++++++++++++++++++++
>  8 files changed, 100 insertions(+), 8 deletions(-)
>  create mode 100644 xen/arch/arm/arm32/mpu/p2m.c
>  create mode 100644 xen/arch/arm/arm32/mpu/smpboot.c
>  create mode 100644 xen/arch/arm/mpu/domain_page.c
> 
> diff --git a/xen/arch/arm/arm32/mpu/Makefile b/xen/arch/arm/arm32/mpu/Makefile
> index 3340058c08..38797f28af 100644
> --- a/xen/arch/arm/arm32/mpu/Makefile
> +++ b/xen/arch/arm/arm32/mpu/Makefile
> @@ -1 +1,3 @@
>  obj-y += head.o
> +obj-y += smpboot.o
> +obj-y += p2m.o
Sort alphabetically. Always.

> diff --git a/xen/arch/arm/arm32/mpu/p2m.c b/xen/arch/arm/arm32/mpu/p2m.c
> new file mode 100644
> index 0000000000..df8de5c7d8
> --- /dev/null
> +++ b/xen/arch/arm/arm32/mpu/p2m.c
> @@ -0,0 +1,18 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#include <xen/init.h>
> +#include <asm/p2m.h>
> +
> +void __init setup_virt_paging(void)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/arm/arm32/mpu/smpboot.c b/xen/arch/arm/arm32/mpu/smpboot.c
> new file mode 100644
> index 0000000000..3f3e54294e
> --- /dev/null
> +++ b/xen/arch/arm/arm32/mpu/smpboot.c
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#include <xen/mm.h>
> +
> +int prepare_secondary_mm(int cpu)
> +{
> +    BUG_ON("unimplemented");
> +    return -EINVAL;
> +}
> +
> +void update_boot_mapping(bool enable)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
> index fbffaccef4..5b67c0f8bb 100644
> --- a/xen/arch/arm/include/asm/mm.h
> +++ b/xen/arch/arm/include/asm/mm.h
> @@ -170,14 +170,7 @@ struct page_info
>  #define _PGC_need_scrub   _PGC_allocated
>  #define PGC_need_scrub    PGC_allocated
>  
> -#ifdef CONFIG_ARM_32
> -#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
> -#define is_xen_heap_mfn(mfn) ({                                 \
> -    unsigned long mfn_ = mfn_x(mfn);                            \
> -    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
> -     mfn_ < mfn_x(directmap_mfn_end));                          \
> -})
> -#else
At first sight, it's not clear why we diverge here and move Arm32 but not Arm64.
At least I'd expect some reasoning for this change in commit msg.

> +#ifdef CONFIG_ARM_64
>  #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap)
>  #define is_xen_heap_mfn(mfn) \
>      (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
> diff --git a/xen/arch/arm/include/asm/mmu/mm.h b/xen/arch/arm/include/asm/mmu/mm.h
> index caba987edc..9b98d12b07 100644
> --- a/xen/arch/arm/include/asm/mmu/mm.h
> +++ b/xen/arch/arm/include/asm/mmu/mm.h
> @@ -21,6 +21,15 @@ extern unsigned long directmap_base_pdx;
>  
>  #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
>  
> +#ifdef CONFIG_ARM_32
Why another #ifdef if there is one a few lines below in this file (below
virt_to_maddr)?

> +#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
> +#define is_xen_heap_mfn(mfn) ({                                 \
> +    unsigned long mfn_ = mfn_x(mfn);                            \
> +    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
> +     mfn_ < mfn_x(directmap_mfn_end));                          \
> +})
> +#endif
> +
>  #define virt_to_maddr(va) ({                                                   \
>      vaddr_t va_ = (vaddr_t)(va);                                               \
>      (paddr_t)((va_to_par(va_) & PADDR_MASK & PAGE_MASK) | (va_ & ~PAGE_MASK)); \
> diff --git a/xen/arch/arm/include/asm/mpu/mm.h b/xen/arch/arm/include/asm/mpu/mm.h
> index 86f33d9836..bfd840fa5d 100644
> --- a/xen/arch/arm/include/asm/mpu/mm.h
> +++ b/xen/arch/arm/include/asm/mpu/mm.h
> @@ -13,6 +13,11 @@ extern struct page_info *frame_table;
>  
>  #define virt_to_maddr(va) ((paddr_t)((vaddr_t)(va) & PADDR_MASK))
>  
> +#ifdef CONFIG_ARM_32
> +#define is_xen_heap_page(page) ({ BUG_ON("unimplemented"); false; })
> +#define is_xen_heap_mfn(mfn) ({ BUG_ON("unimplemented"); false; })
> +#endif
> +
>  /* On MPU systems there is no translation, ma == va. */
>  static inline void *maddr_to_virt(paddr_t ma)
>  {
> diff --git a/xen/arch/arm/mpu/Makefile b/xen/arch/arm/mpu/Makefile
> index 21bbc517b5..ff221011d5 100644
> --- a/xen/arch/arm/mpu/Makefile
> +++ b/xen/arch/arm/mpu/Makefile
> @@ -2,3 +2,4 @@ obj-y += mm.o
>  obj-y += p2m.o
>  obj-y += setup.init.o
>  obj-y += vmap.o
> +obj-$(CONFIG_ARM_32) += domain_page.o
Again, sort alphabetically.

> diff --git a/xen/arch/arm/mpu/domain_page.c b/xen/arch/arm/mpu/domain_page.c
> new file mode 100644
> index 0000000000..8859b24e04
> --- /dev/null
> +++ b/xen/arch/arm/mpu/domain_page.c
> @@ -0,0 +1,41 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
empty line here

> +#include <xen/domain_page.h>
> +
> +void *map_domain_page_global(mfn_t mfn)
> +{
> +    BUG_ON("unimplemented");
> +    return NULL;
> +}
> +
> +/* Map a page of domheap memory */
> +void *map_domain_page(mfn_t mfn)
> +{
> +    BUG_ON("unimplemented");
> +    return NULL;
> +}
> +
> +/* Release a mapping taken with map_domain_page() */
> +void unmap_domain_page(const void *ptr)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +mfn_t domain_page_map_to_mfn(const void *ptr)
> +{
> +    BUG_ON("unimplemented");
> +    return INVALID_MFN;
> +}
> +
> +void unmap_domain_page_global(const void *va)
> +{
> +    BUG_ON("unimplemented");
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */

Additionally, take into account Luca remarks regarding headers.

~Michal
Ayan Kumar Halder April 11, 2025, 10:04 a.m. UTC | #3
Hi,

On 08/04/2025 10:54, Orzel, Michal wrote:
>
> On 07/04/2025 20:44, Ayan Kumar Halder wrote:
>> Add stubs to enable compilation
> NIT: missing dot at the end of sentence.
>
>> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
>> ---
>> Changes from :-
>>
>> v1, v2 -
>> 1. New patch introduced in v3.
>> 2. Should be applied on top of
>> https://patchwork.kernel.org/project/xen-devel/cover/20250316192445.2376484-1-luca.fancellu@arm.com/
>>
>> v3 -
>> 1. Add stubs for map_domain_page() and similar functions.
>>
>> 2. 'BUG_ON("unimplemented")' is kept in all the stubs.
>>
>> v4 -
>> 1. is_xen_heap_mfn() macros are defined across mpu/mm.h (ARM32 specific)
>> , mmu/mm.h (ARM32 specific) and asm/mm.h (ARM64 specific)
>>
>> 2. s/(void*)0/NULL
>>
>>   xen/arch/arm/arm32/mpu/Makefile   |  2 ++
>>   xen/arch/arm/arm32/mpu/p2m.c      | 18 ++++++++++++++
>>   xen/arch/arm/arm32/mpu/smpboot.c  | 23 +++++++++++++++++
>>   xen/arch/arm/include/asm/mm.h     |  9 +------
>>   xen/arch/arm/include/asm/mmu/mm.h |  9 +++++++
>>   xen/arch/arm/include/asm/mpu/mm.h |  5 ++++
>>   xen/arch/arm/mpu/Makefile         |  1 +
>>   xen/arch/arm/mpu/domain_page.c    | 41 +++++++++++++++++++++++++++++++
>>   8 files changed, 100 insertions(+), 8 deletions(-)
>>   create mode 100644 xen/arch/arm/arm32/mpu/p2m.c
>>   create mode 100644 xen/arch/arm/arm32/mpu/smpboot.c
>>   create mode 100644 xen/arch/arm/mpu/domain_page.c
>>
>> diff --git a/xen/arch/arm/arm32/mpu/Makefile b/xen/arch/arm/arm32/mpu/Makefile
>> index 3340058c08..38797f28af 100644
>> --- a/xen/arch/arm/arm32/mpu/Makefile
>> +++ b/xen/arch/arm/arm32/mpu/Makefile
>> @@ -1 +1,3 @@
>>   obj-y += head.o
>> +obj-y += smpboot.o
>> +obj-y += p2m.o
> Sort alphabetically. Always.
>
>> diff --git a/xen/arch/arm/arm32/mpu/p2m.c b/xen/arch/arm/arm32/mpu/p2m.c
>> new file mode 100644
>> index 0000000000..df8de5c7d8
>> --- /dev/null
>> +++ b/xen/arch/arm/arm32/mpu/p2m.c
>> @@ -0,0 +1,18 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +
>> +#include <xen/init.h>
>> +#include <asm/p2m.h>
>> +
>> +void __init setup_virt_paging(void)
>> +{
>> +    BUG_ON("unimplemented");
>> +}
>> +
>> +/*
>> + * Local variables:
>> + * mode: C
>> + * c-file-style: "BSD"
>> + * c-basic-offset: 4
>> + * indent-tabs-mode: nil
>> + * End:
>> + */
>> diff --git a/xen/arch/arm/arm32/mpu/smpboot.c b/xen/arch/arm/arm32/mpu/smpboot.c
>> new file mode 100644
>> index 0000000000..3f3e54294e
>> --- /dev/null
>> +++ b/xen/arch/arm/arm32/mpu/smpboot.c
>> @@ -0,0 +1,23 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +
>> +#include <xen/mm.h>
>> +
>> +int prepare_secondary_mm(int cpu)
>> +{
>> +    BUG_ON("unimplemented");
>> +    return -EINVAL;
>> +}
>> +
>> +void update_boot_mapping(bool enable)
>> +{
>> +    BUG_ON("unimplemented");
>> +}
>> +
>> +/*
>> + * Local variables:
>> + * mode: C
>> + * c-file-style: "BSD"
>> + * c-basic-offset: 4
>> + * indent-tabs-mode: nil
>> + * End:
>> + */
>> diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
>> index fbffaccef4..5b67c0f8bb 100644
>> --- a/xen/arch/arm/include/asm/mm.h
>> +++ b/xen/arch/arm/include/asm/mm.h
>> @@ -170,14 +170,7 @@ struct page_info
>>   #define _PGC_need_scrub   _PGC_allocated
>>   #define PGC_need_scrub    PGC_allocated
>>   
>> -#ifdef CONFIG_ARM_32
>> -#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
>> -#define is_xen_heap_mfn(mfn) ({                                 \
>> -    unsigned long mfn_ = mfn_x(mfn);                            \
>> -    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
>> -     mfn_ < mfn_x(directmap_mfn_end));                          \
>> -})
>> -#else
> At first sight, it's not clear why we diverge here and move Arm32 but not Arm64.
> At least I'd expect some reasoning for this change in commit msg.
I added an explaination why the code is moved for Arm32 in my latest patch.
>
>> +#ifdef CONFIG_ARM_64
>>   #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap)
>>   #define is_xen_heap_mfn(mfn) \
>>       (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
>> diff --git a/xen/arch/arm/include/asm/mmu/mm.h b/xen/arch/arm/include/asm/mmu/mm.h
>> index caba987edc..9b98d12b07 100644
>> --- a/xen/arch/arm/include/asm/mmu/mm.h
>> +++ b/xen/arch/arm/include/asm/mmu/mm.h
>> @@ -21,6 +21,15 @@ extern unsigned long directmap_base_pdx;
>>   
>>   #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
>>   
>> +#ifdef CONFIG_ARM_32
> Why another #ifdef if there is one a few lines below in this file (below
> virt_to_maddr)?
Ack. I have moved it.
>
>> +#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
>> +#define is_xen_heap_mfn(mfn) ({                                 \
>> +    unsigned long mfn_ = mfn_x(mfn);                            \
>> +    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
>> +     mfn_ < mfn_x(directmap_mfn_end));                          \
>> +})
>> +#endif
>> +
>>   #define virt_to_maddr(va) ({                                                   \
>>       vaddr_t va_ = (vaddr_t)(va);                                               \
>>       (paddr_t)((va_to_par(va_) & PADDR_MASK & PAGE_MASK) | (va_ & ~PAGE_MASK)); \
>> diff --git a/xen/arch/arm/include/asm/mpu/mm.h b/xen/arch/arm/include/asm/mpu/mm.h
>> index 86f33d9836..bfd840fa5d 100644
>> --- a/xen/arch/arm/include/asm/mpu/mm.h
>> +++ b/xen/arch/arm/include/asm/mpu/mm.h
>> @@ -13,6 +13,11 @@ extern struct page_info *frame_table;
>>   
>>   #define virt_to_maddr(va) ((paddr_t)((vaddr_t)(va) & PADDR_MASK))
>>   
>> +#ifdef CONFIG_ARM_32
>> +#define is_xen_heap_page(page) ({ BUG_ON("unimplemented"); false; })
>> +#define is_xen_heap_mfn(mfn) ({ BUG_ON("unimplemented"); false; })
>> +#endif
>> +
>>   /* On MPU systems there is no translation, ma == va. */
>>   static inline void *maddr_to_virt(paddr_t ma)
>>   {
>> diff --git a/xen/arch/arm/mpu/Makefile b/xen/arch/arm/mpu/Makefile
>> index 21bbc517b5..ff221011d5 100644
>> --- a/xen/arch/arm/mpu/Makefile
>> +++ b/xen/arch/arm/mpu/Makefile
>> @@ -2,3 +2,4 @@ obj-y += mm.o
>>   obj-y += p2m.o
>>   obj-y += setup.init.o
>>   obj-y += vmap.o
>> +obj-$(CONFIG_ARM_32) += domain_page.o
> Again, sort alphabetically.
>
>> diff --git a/xen/arch/arm/mpu/domain_page.c b/xen/arch/arm/mpu/domain_page.c
>> new file mode 100644
>> index 0000000000..8859b24e04
>> --- /dev/null
>> +++ b/xen/arch/arm/mpu/domain_page.c
>> @@ -0,0 +1,41 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> empty line here
>
>> +#include <xen/domain_page.h>
>> +
>> +void *map_domain_page_global(mfn_t mfn)
>> +{
>> +    BUG_ON("unimplemented");
>> +    return NULL;
>> +}
>> +
>> +/* Map a page of domheap memory */
>> +void *map_domain_page(mfn_t mfn)
>> +{
>> +    BUG_ON("unimplemented");
>> +    return NULL;
>> +}
>> +
>> +/* Release a mapping taken with map_domain_page() */
>> +void unmap_domain_page(const void *ptr)
>> +{
>> +    BUG_ON("unimplemented");
>> +}
>> +
>> +mfn_t domain_page_map_to_mfn(const void *ptr)
>> +{
>> +    BUG_ON("unimplemented");
>> +    return INVALID_MFN;
>> +}
>> +
>> +void unmap_domain_page_global(const void *va)
>> +{
>> +    BUG_ON("unimplemented");
>> +}
>> +
>> +/*
>> + * Local variables:
>> + * mode: C
>> + * c-file-style: "BSD"
>> + * c-basic-offset: 4
>> + * indent-tabs-mode: nil
>> + * End:
>> + */
> Additionally, take into account Luca remarks regarding headers.

Thanks Luca for spotting them.

I have addressed all the other comments.

- Ayan

>
> ~Michal
>
>
diff mbox series

Patch

diff --git a/xen/arch/arm/arm32/mpu/Makefile b/xen/arch/arm/arm32/mpu/Makefile
index 3340058c08..38797f28af 100644
--- a/xen/arch/arm/arm32/mpu/Makefile
+++ b/xen/arch/arm/arm32/mpu/Makefile
@@ -1 +1,3 @@ 
 obj-y += head.o
+obj-y += smpboot.o
+obj-y += p2m.o
diff --git a/xen/arch/arm/arm32/mpu/p2m.c b/xen/arch/arm/arm32/mpu/p2m.c
new file mode 100644
index 0000000000..df8de5c7d8
--- /dev/null
+++ b/xen/arch/arm/arm32/mpu/p2m.c
@@ -0,0 +1,18 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <xen/init.h>
+#include <asm/p2m.h>
+
+void __init setup_virt_paging(void)
+{
+    BUG_ON("unimplemented");
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/arm32/mpu/smpboot.c b/xen/arch/arm/arm32/mpu/smpboot.c
new file mode 100644
index 0000000000..3f3e54294e
--- /dev/null
+++ b/xen/arch/arm/arm32/mpu/smpboot.c
@@ -0,0 +1,23 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <xen/mm.h>
+
+int prepare_secondary_mm(int cpu)
+{
+    BUG_ON("unimplemented");
+    return -EINVAL;
+}
+
+void update_boot_mapping(bool enable)
+{
+    BUG_ON("unimplemented");
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
index fbffaccef4..5b67c0f8bb 100644
--- a/xen/arch/arm/include/asm/mm.h
+++ b/xen/arch/arm/include/asm/mm.h
@@ -170,14 +170,7 @@  struct page_info
 #define _PGC_need_scrub   _PGC_allocated
 #define PGC_need_scrub    PGC_allocated
 
-#ifdef CONFIG_ARM_32
-#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
-#define is_xen_heap_mfn(mfn) ({                                 \
-    unsigned long mfn_ = mfn_x(mfn);                            \
-    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
-     mfn_ < mfn_x(directmap_mfn_end));                          \
-})
-#else
+#ifdef CONFIG_ARM_64
 #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap)
 #define is_xen_heap_mfn(mfn) \
     (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
diff --git a/xen/arch/arm/include/asm/mmu/mm.h b/xen/arch/arm/include/asm/mmu/mm.h
index caba987edc..9b98d12b07 100644
--- a/xen/arch/arm/include/asm/mmu/mm.h
+++ b/xen/arch/arm/include/asm/mmu/mm.h
@@ -21,6 +21,15 @@  extern unsigned long directmap_base_pdx;
 
 #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
 
+#ifdef CONFIG_ARM_32
+#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
+#define is_xen_heap_mfn(mfn) ({                                 \
+    unsigned long mfn_ = mfn_x(mfn);                            \
+    (mfn_ >= mfn_x(directmap_mfn_start) &&                      \
+     mfn_ < mfn_x(directmap_mfn_end));                          \
+})
+#endif
+
 #define virt_to_maddr(va) ({                                                   \
     vaddr_t va_ = (vaddr_t)(va);                                               \
     (paddr_t)((va_to_par(va_) & PADDR_MASK & PAGE_MASK) | (va_ & ~PAGE_MASK)); \
diff --git a/xen/arch/arm/include/asm/mpu/mm.h b/xen/arch/arm/include/asm/mpu/mm.h
index 86f33d9836..bfd840fa5d 100644
--- a/xen/arch/arm/include/asm/mpu/mm.h
+++ b/xen/arch/arm/include/asm/mpu/mm.h
@@ -13,6 +13,11 @@  extern struct page_info *frame_table;
 
 #define virt_to_maddr(va) ((paddr_t)((vaddr_t)(va) & PADDR_MASK))
 
+#ifdef CONFIG_ARM_32
+#define is_xen_heap_page(page) ({ BUG_ON("unimplemented"); false; })
+#define is_xen_heap_mfn(mfn) ({ BUG_ON("unimplemented"); false; })
+#endif
+
 /* On MPU systems there is no translation, ma == va. */
 static inline void *maddr_to_virt(paddr_t ma)
 {
diff --git a/xen/arch/arm/mpu/Makefile b/xen/arch/arm/mpu/Makefile
index 21bbc517b5..ff221011d5 100644
--- a/xen/arch/arm/mpu/Makefile
+++ b/xen/arch/arm/mpu/Makefile
@@ -2,3 +2,4 @@  obj-y += mm.o
 obj-y += p2m.o
 obj-y += setup.init.o
 obj-y += vmap.o
+obj-$(CONFIG_ARM_32) += domain_page.o
diff --git a/xen/arch/arm/mpu/domain_page.c b/xen/arch/arm/mpu/domain_page.c
new file mode 100644
index 0000000000..8859b24e04
--- /dev/null
+++ b/xen/arch/arm/mpu/domain_page.c
@@ -0,0 +1,41 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <xen/domain_page.h>
+
+void *map_domain_page_global(mfn_t mfn)
+{
+    BUG_ON("unimplemented");
+    return NULL;
+}
+
+/* Map a page of domheap memory */
+void *map_domain_page(mfn_t mfn)
+{
+    BUG_ON("unimplemented");
+    return NULL;
+}
+
+/* Release a mapping taken with map_domain_page() */
+void unmap_domain_page(const void *ptr)
+{
+    BUG_ON("unimplemented");
+}
+
+mfn_t domain_page_map_to_mfn(const void *ptr)
+{
+    BUG_ON("unimplemented");
+    return INVALID_MFN;
+}
+
+void unmap_domain_page_global(const void *va)
+{
+    BUG_ON("unimplemented");
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */