Skip to contentSkip to conversation

x86/mm: Use standard C types for sized integers

PATCH In review Frediano Ziglio 2 participants 4 messages Oct 30, 2024

lore
Share & tools
lore
#0 lore raw

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

The header is already using these types.

---
 xen/arch/x86/include/asm/mm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/x86/include/asm/mm.h +3 -3
index 2a837f3d59..71a29b2cb3 100644
@@ -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;
         };
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Frediano Ziglio

The header is already using these types.

Nevertheless I wonder whether ...

Quoted 12 lines
xen/arch/x86/include/asm/mm.h +1 -1
@@ -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

xen/arch/x86/include/asm/mm.h struct page_info · line 289

Quoted 8 lines
xen/arch/x86/include/asm/mm.h +2 -2
@@ -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.

xen/arch/x86/include/asm/mm.h struct page_info · line 290

Quoted 1 line
xen/arch/x86/include/asm/mm.h +0 -0
             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

#2 lore raw
Quoted 8 lines · Jan Beulich
Quoted 3 lines · Frediano Ziglio

The header is already using these types.

Thanks

Quoted 11 lines

Nevertheless I wonder whether ...

Quoted 9 lines
xen/arch/x86/include/asm/mm.h +1 -1
@@ -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;
 
Quoted 14 lines

xen/arch/x86/include/asm/mm.h struct page_info · line 289

Quoted 11 lines
xen/arch/x86/include/asm/mm.h +2 -2
         /*
          * 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.

Quoted 6 lines

xen/arch/x86/include/asm/mm.h struct page_info · line 290

Quoted 1 line
xen/arch/x86/include/asm/mm.h +0 -0
             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.

Quoted 3 lines

).

Jan

Frediano

#3 lore raw
Quoted 6 lines · Frediano Ziglio
Quoted 3 lines · Jan Beulich

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