[PATCH v5 3/3] ppc/mm: Introduce mm-types.h

Andrew Cooper posted 3 patches 7 months, 4 weeks ago
[PATCH v5 3/3] ppc/mm: Introduce mm-types.h
Posted by Andrew Cooper 7 months, 4 weeks ago
From: Shawn Anastasio <sanastasio@raptorengineering.com>

Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Shawn Anastasio <sanastasio@raptorengineering.com>

Possibly not for taking on it's own (might be better with the PPC
implemenation of map_pages_to_xen()).

Nevertheless, this patch alone now does trip:

  diff --git a/xen/common/vmap.c b/xen/common/vmap.c
  index d6991421f3f7..9552806dba39 100644
  --- a/xen/common/vmap.c
  +++ b/xen/common/vmap.c
  @@ -228,6 +228,8 @@ void *__vmap(const mfn_t *mfn, unsigned int granularity,
       void *va = vm_alloc(nr * granularity, align, type);
       unsigned long cur = (unsigned long)va;

  +    BUILD_BUG_ON(sizeof(pte_attr_t) != 4);
  +
       for ( ; va && nr--; ++mfn, cur += PAGE_SIZE * granularity )
       {
           if ( map_pages_to_xen(cur, *mfn, granularity, flags) )

in PPC builds only.
---
 xen/arch/ppc/include/asm/mm-types.h | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 xen/arch/ppc/include/asm/mm-types.h

diff --git a/xen/arch/ppc/include/asm/mm-types.h b/xen/arch/ppc/include/asm/mm-types.h
new file mode 100644
index 000000000000..06a3af1c6eda
--- /dev/null
+++ b/xen/arch/ppc/include/asm/mm-types.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef PPC_MM_TYPES_H
+#define PPC_MM_TYPES_H
+
+typedef unsigned long pte_attr_t;
+
+#endif /* PPC_MM_TYPES_H */
-- 
2.39.5


Re: [PATCH v5 3/3] ppc/mm: Introduce mm-types.h
Posted by Oleksii Kurochko 7 months, 4 weeks ago
On 4/25/25 1:24 PM, Andrew Cooper wrote:
> From: Shawn Anastasio<sanastasio@raptorengineering.com>
>
> Signed-off-by: Shawn Anastasio<sanastasio@raptorengineering.com>
> ---
> CC: Jan Beulich<JBeulich@suse.com>
> CC: Roger Pau Monné<roger.pau@citrix.com>
> CC: Stefano Stabellini<sstabellini@kernel.org>
> CC: Julien Grall<julien@xen.org>
> CC: Volodymyr Babchuk<Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis<bertrand.marquis@arm.com>
> CC: Michal Orzel<michal.orzel@amd.com>
> CC: Oleksii Kurochko<oleksii.kurochko@gmail.com>
> CC: Shawn Anastasio<sanastasio@raptorengineering.com>
>
> Possibly not for taking on it's own (might be better with the PPC
> implemenation of map_pages_to_xen()).
>
> Nevertheless, this patch alone now does trip:
>
>    diff --git a/xen/common/vmap.c b/xen/common/vmap.c
>    index d6991421f3f7..9552806dba39 100644
>    --- a/xen/common/vmap.c
>    +++ b/xen/common/vmap.c
>    @@ -228,6 +228,8 @@ void *__vmap(const mfn_t *mfn, unsigned int granularity,
>         void *va = vm_alloc(nr * granularity, align, type);
>         unsigned long cur = (unsigned long)va;
>
>    +    BUILD_BUG_ON(sizeof(pte_attr_t) != 4);
>    +

Could you please clarify what kind of changes should done in the case if
sizeof(pte_attr_t) == 8 (unsigned long)?

~ Oleksii

>         for ( ; va && nr--; ++mfn, cur += PAGE_SIZE * granularity )
>         {
>             if ( map_pages_to_xen(cur, *mfn, granularity, flags) )
>
> in PPC builds only.
> ---
>   xen/arch/ppc/include/asm/mm-types.h | 7 +++++++
>   1 file changed, 7 insertions(+)
>   create mode 100644 xen/arch/ppc/include/asm/mm-types.h
>
> diff --git a/xen/arch/ppc/include/asm/mm-types.h b/xen/arch/ppc/include/asm/mm-types.h
> new file mode 100644
> index 000000000000..06a3af1c6eda
> --- /dev/null
> +++ b/xen/arch/ppc/include/asm/mm-types.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +#ifndef PPC_MM_TYPES_H
> +#define PPC_MM_TYPES_H
> +
> +typedef unsigned long pte_attr_t;
> +
> +#endif /* PPC_MM_TYPES_H */
Re: [PATCH v5 3/3] ppc/mm: Introduce mm-types.h
Posted by Andrew Cooper 7 months, 4 weeks ago
On 25/04/2025 12:37 pm, Oleksii Kurochko wrote:
>
>
> On 4/25/25 1:24 PM, Andrew Cooper wrote:
>> From: Shawn Anastasio <sanastasio@raptorengineering.com>
>>
>> Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
>> ---
>> CC: Jan Beulich <JBeulich@suse.com>
>> CC: Roger Pau Monné <roger.pau@citrix.com>
>> CC: Stefano Stabellini <sstabellini@kernel.org>
>> CC: Julien Grall <julien@xen.org>
>> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
>> CC: Bertrand Marquis <bertrand.marquis@arm.com>
>> CC: Michal Orzel <michal.orzel@amd.com>
>> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>> CC: Shawn Anastasio <sanastasio@raptorengineering.com>
>>
>> Possibly not for taking on it's own (might be better with the PPC
>> implemenation of map_pages_to_xen()).
>>
>> Nevertheless, this patch alone now does trip:
>>
>>   diff --git a/xen/common/vmap.c b/xen/common/vmap.c
>>   index d6991421f3f7..9552806dba39 100644
>>   --- a/xen/common/vmap.c
>>   +++ b/xen/common/vmap.c
>>   @@ -228,6 +228,8 @@ void *__vmap(const mfn_t *mfn, unsigned int granularity,
>>        void *va = vm_alloc(nr * granularity, align, type);
>>        unsigned long cur = (unsigned long)va;
>>
>>   +    BUILD_BUG_ON(sizeof(pte_attr_t) != 4);
>>   +
> Could you please clarify what kind of changes should done in the case if 
> sizeof(pte_attr_t) == 8 (unsigned long)?

Nothing.  This is simply to demonstrate that __has_include() is working,
and is making PPC different to all the other architectures.

~Andrew.