[PATCH] x86/mm: Use standard C types for sized integers

Frediano Ziglio posted 1 patch 3 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20241030104406.2173357-2-frediano.ziglio@cloud.com
xen/arch/x86/include/asm/mm.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] x86/mm: Use standard C types for sized integers
Posted by Frediano Ziglio 3 weeks, 1 day ago
The header is already using these types.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
---
 xen/arch/x86/include/asm/mm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/include/asm/mm.h b/xen/arch/x86/include/asm/mm.h
index 2a837f3d59..71a29b2cb3 100644
--- a/xen/arch/x86/include/asm/mm.h
+++ b/xen/arch/x86/include/asm/mm.h
@@ -230,7 +230,7 @@ struct page_info
          * Only valid for: a) free pages, and b) pages with zero type count
          * (except page table pages when the guest is in shadow mode).
          */
-        u32 tlbflush_timestamp;
+        uint32_t tlbflush_timestamp;
 
         /*
          * When PGT_partial is true then the first two fields are valid and
@@ -284,8 +284,8 @@ struct page_info
          *   in use.
          */
         struct {
-            u16 nr_validated_ptes:PAGETABLE_ORDER + 1;
-            u16 :16 - PAGETABLE_ORDER - 1 - 1;
+            uint16_t nr_validated_ptes:PAGETABLE_ORDER + 1;
+            uint16_t :16 - PAGETABLE_ORDER - 1 - 1;
             uint16_t partial_flags:1;
             int16_t linear_pt_count;
         };
-- 
2.34.1
Re: [PATCH] x86/mm: Use standard C types for sized integers
Posted by Jan Beulich 3 weeks, 1 day ago
On 30.10.2024 11:44, Frediano Ziglio wrote:
> The header is already using these types.
> 
> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

Nevertheless I wonder whether ...

> --- a/xen/arch/x86/include/asm/mm.h
> +++ b/xen/arch/x86/include/asm/mm.h
> @@ -230,7 +230,7 @@ struct page_info
>           * Only valid for: a) free pages, and b) pages with zero type count
>           * (except page table pages when the guest is in shadow mode).
>           */
> -        u32 tlbflush_timestamp;
> +        uint32_t tlbflush_timestamp;
>  
>          /*
>           * When PGT_partial is true then the first two fields are valid and
> @@ -284,8 +284,8 @@ struct page_info
>           *   in use.
>           */
>          struct {
> -            u16 nr_validated_ptes:PAGETABLE_ORDER + 1;
> -            u16 :16 - PAGETABLE_ORDER - 1 - 1;
> +            uint16_t nr_validated_ptes:PAGETABLE_ORDER + 1;
> +            uint16_t :16 - PAGETABLE_ORDER - 1 - 1;
>              uint16_t partial_flags:1;

... fixed width types are really needed here; afaict unsigned int ought to do.

>              int16_t linear_pt_count;

It's only here where the fixed width type is largely needed (or alternatively

            signed int linear_pt_count:16;

).

Jan
Re: [PATCH] x86/mm: Use standard C types for sized integers
Posted by Frediano Ziglio 3 weeks, 1 day ago
On Wed, Oct 30, 2024 at 11:02 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 30.10.2024 11:44, Frediano Ziglio wrote:
> > The header is already using these types.
> >
> > Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
>
> Acked-by: Jan Beulich <jbeulich@suse.com>
>

Thanks

> Nevertheless I wonder whether ...
>
> > --- a/xen/arch/x86/include/asm/mm.h
> > +++ b/xen/arch/x86/include/asm/mm.h
> > @@ -230,7 +230,7 @@ struct page_info
> >           * Only valid for: a) free pages, and b) pages with zero type count
> >           * (except page table pages when the guest is in shadow mode).
> >           */
> > -        u32 tlbflush_timestamp;
> > +        uint32_t tlbflush_timestamp;
> >
> >          /*
> >           * When PGT_partial is true then the first two fields are valid and
> > @@ -284,8 +284,8 @@ struct page_info
> >           *   in use.
> >           */
> >          struct {
> > -            u16 nr_validated_ptes:PAGETABLE_ORDER + 1;
> > -            u16 :16 - PAGETABLE_ORDER - 1 - 1;
> > +            uint16_t nr_validated_ptes:PAGETABLE_ORDER + 1;
> > +            uint16_t :16 - PAGETABLE_ORDER - 1 - 1;
> >              uint16_t partial_flags:1;
>
> ... fixed width types are really needed here; afaict unsigned int ought to do.
>

Not for gcc/clang. Other compilers (like MS one) differs... in our
case this is not a public header and we only support gcc/clang so
unsigned/int would be the same.

> >              int16_t linear_pt_count;
>
> It's only here where the fixed width type is largely needed (or alternatively
>
>             signed int linear_pt_count:16;
>

That would be different. Compilers do not allow to take addresses of bit-fields.

> ).
>
> Jan

Frediano
Re: [PATCH] x86/mm: Use standard C types for sized integers
Posted by Jan Beulich 3 weeks, 1 day ago
On 30.10.2024 12:10, Frediano Ziglio wrote:
> On Wed, Oct 30, 2024 at 11:02 AM Jan Beulich <jbeulich@suse.com> wrote:
>> It's only here where the fixed width type is largely needed (or alternatively
>>
>>             signed int linear_pt_count:16;
> 
> That would be different. Compilers do not allow to take addresses of bit-fields.

Oh, right, I forgot we take the address of this field in a few places.

Jan