[PATCH] xen/multiboot: Make headers be standalone

Andrew Cooper posted 1 patch 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20241113185118.1786703-1-andrew.cooper3@citrix.com
xen/include/xen/multiboot.h  | 68 +++++++++++++++++++-----------------
xen/include/xen/multiboot2.h |  3 ++
2 files changed, 38 insertions(+), 33 deletions(-)
[PATCH] xen/multiboot: Make headers be standalone
Posted by Andrew Cooper 1 week ago
Both require xen/types.h.

Change multiboot.h to include const.h by it's more normal path, and swap u32
for uint32_t.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/include/xen/multiboot.h  | 68 +++++++++++++++++++-----------------
 xen/include/xen/multiboot2.h |  3 ++
 2 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/xen/include/xen/multiboot.h b/xen/include/xen/multiboot.h
index 80a1761d9ee7..7ba86aab73d8 100644
--- a/xen/include/xen/multiboot.h
+++ b/xen/include/xen/multiboot.h
@@ -17,7 +17,7 @@
 #ifndef __MULTIBOOT_H__
 #define __MULTIBOOT_H__
 
-#include "const.h"
+#include <xen/const.h>
 
 /*
  * Multiboot header structure.
@@ -45,41 +45,43 @@
 
 #ifndef __ASSEMBLY__
 
+#include <xen/types.h>
+
 /* The symbol table for a.out.  */
 struct aout_symbol_table {
-    u32 tabsize;
-    u32 strsize;
-    u32 addr;
-    u32 reserved;
+    uint32_t tabsize;
+    uint32_t strsize;
+    uint32_t addr;
+    uint32_t reserved;
 };
 typedef struct aout_symbol_table aout_symbol_table_t;
 
 /* The section header table for ELF.  */
 struct elf_section_header_table {
-    u32 num;
-    u32 size;
-    u32 addr;
-    u32 shndx;
+    uint32_t num;
+    uint32_t size;
+    uint32_t addr;
+    uint32_t shndx;
 };
 typedef struct elf_section_header_table elf_section_header_table_t;
 
 /* The Multiboot information.  */
 struct multiboot_info {
-    u32 flags;
+    uint32_t flags;
 
     /* Valid if flags sets MBI_MEMLIMITS */
-    u32 mem_lower;
-    u32 mem_upper;
+    uint32_t mem_lower;
+    uint32_t mem_upper;
 
     /* Valid if flags sets MBI_BOOTDEV */
-    u32 boot_device;
+    uint32_t boot_device;
 
     /* Valid if flags sets MBI_CMDLINE */
-    u32 cmdline;
+    uint32_t cmdline;
 
     /* Valid if flags sets MBI_MODULES */
-    u32 mods_count;
-    u32 mods_addr;
+    uint32_t mods_count;
+    uint32_t mods_addr;
 
     /* Valid if flags sets ... */
     union {
@@ -88,42 +90,42 @@ struct multiboot_info {
     } u;
 
     /* Valid if flags sets MBI_MEMMAP */
-    u32 mmap_length;
-    u32 mmap_addr;
+    uint32_t mmap_length;
+    uint32_t mmap_addr;
 
     /* Valid if flags sets MBI_DRIVES */
-    u32 drives_length;
-    u32 drives_addr;
+    uint32_t drives_length;
+    uint32_t drives_addr;
 
     /* Valid if flags sets MBI_BIOSCONFIG */
-    u32 config_table;
+    uint32_t config_table;
 
     /* Valid if flags sets MBI_LOADERNAME */
-    u32 boot_loader_name;
+    uint32_t boot_loader_name;
 
     /* Valid if flags sets MBI_APM */
-    u32 apm_table;
+    uint32_t apm_table;
 };
 typedef struct multiboot_info multiboot_info_t;
 
 /* The module structure.  */
 struct module {
-    u32 mod_start;
-    u32 mod_end;
-    u32 string;
-    u32 reserved;
+    uint32_t mod_start;
+    uint32_t mod_end;
+    uint32_t string;
+    uint32_t reserved;
 };
 typedef struct module module_t;
 
 /* The memory map. Be careful that the offset 0 is base_addr_low
    but no size.  */
 struct memory_map {
-    u32 size;
-    u32 base_addr_low;
-    u32 base_addr_high;
-    u32 length_low;
-    u32 length_high;
-    u32 type;
+    uint32_t size;
+    uint32_t base_addr_low;
+    uint32_t base_addr_high;
+    uint32_t length_low;
+    uint32_t length_high;
+    uint32_t type;
 };
 typedef struct memory_map memory_map_t;
 
diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h
index 7cda620eec8a..f96f5d4c3169 100644
--- a/xen/include/xen/multiboot2.h
+++ b/xen/include/xen/multiboot2.h
@@ -114,6 +114,9 @@
 #define MULTIBOOT2_FRAMEBUFFER_TYPE_EGA_TEXT            2
 
 #ifndef __ASSEMBLY__
+
+#include <xen/types.h>
+
 typedef struct {
     uint32_t total_size;
     uint32_t reserved;
-- 
2.39.5


Re: [PATCH] xen/multiboot: Make headers be standalone
Posted by Jan Beulich 1 week ago
On 13.11.2024 19:51, Andrew Cooper wrote:
> --- a/xen/include/xen/multiboot.h
> +++ b/xen/include/xen/multiboot.h
> @@ -17,7 +17,7 @@
>  #ifndef __MULTIBOOT_H__
>  #define __MULTIBOOT_H__
>  
> -#include "const.h"
> +#include <xen/const.h>
>  
>  /*
>   * Multiboot header structure.
> @@ -45,41 +45,43 @@
>  
>  #ifndef __ASSEMBLY__
>  
> +#include <xen/types.h>

Isn't xen/stdint.h sufficient to include both here and ...

> --- a/xen/include/xen/multiboot2.h
> +++ b/xen/include/xen/multiboot2.h
> @@ -114,6 +114,9 @@
>  #define MULTIBOOT2_FRAMEBUFFER_TYPE_EGA_TEXT            2
>  
>  #ifndef __ASSEMBLY__
> +
> +#include <xen/types.h>
> +
>  typedef struct {
>      uint32_t total_size;
>      uint32_t reserved;

... here?

Jan
Re: [PATCH] xen/multiboot: Make headers be standalone
Posted by Frediano Ziglio 1 week ago
On Wed, Nov 13, 2024 at 6:51 PM Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>
> Both require xen/types.h.
>
> Change multiboot.h to include const.h by it's more normal path, and swap u32
> for uint32_t.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> ---
>  xen/include/xen/multiboot.h  | 68 +++++++++++++++++++-----------------
>  xen/include/xen/multiboot2.h |  3 ++
>  2 files changed, 38 insertions(+), 33 deletions(-)
>
> diff --git a/xen/include/xen/multiboot.h b/xen/include/xen/multiboot.h
> index 80a1761d9ee7..7ba86aab73d8 100644
> --- a/xen/include/xen/multiboot.h
> +++ b/xen/include/xen/multiboot.h
> @@ -17,7 +17,7 @@
>  #ifndef __MULTIBOOT_H__
>  #define __MULTIBOOT_H__
>
> -#include "const.h"
> +#include <xen/const.h>
>
>  /*
>   * Multiboot header structure.
> @@ -45,41 +45,43 @@
>
>  #ifndef __ASSEMBLY__
>
> +#include <xen/types.h>
> +
>  /* The symbol table for a.out.  */
>  struct aout_symbol_table {
> -    u32 tabsize;
> -    u32 strsize;
> -    u32 addr;
> -    u32 reserved;
> +    uint32_t tabsize;
> +    uint32_t strsize;
> +    uint32_t addr;
> +    uint32_t reserved;
>  };
>  typedef struct aout_symbol_table aout_symbol_table_t;
>
>  /* The section header table for ELF.  */
>  struct elf_section_header_table {
> -    u32 num;
> -    u32 size;
> -    u32 addr;
> -    u32 shndx;
> +    uint32_t num;
> +    uint32_t size;
> +    uint32_t addr;
> +    uint32_t shndx;
>  };
>  typedef struct elf_section_header_table elf_section_header_table_t;
>
>  /* The Multiboot information.  */
>  struct multiboot_info {
> -    u32 flags;
> +    uint32_t flags;
>
>      /* Valid if flags sets MBI_MEMLIMITS */
> -    u32 mem_lower;
> -    u32 mem_upper;
> +    uint32_t mem_lower;
> +    uint32_t mem_upper;
>
>      /* Valid if flags sets MBI_BOOTDEV */
> -    u32 boot_device;
> +    uint32_t boot_device;
>
>      /* Valid if flags sets MBI_CMDLINE */
> -    u32 cmdline;
> +    uint32_t cmdline;
>
>      /* Valid if flags sets MBI_MODULES */
> -    u32 mods_count;
> -    u32 mods_addr;
> +    uint32_t mods_count;
> +    uint32_t mods_addr;
>
>      /* Valid if flags sets ... */
>      union {
> @@ -88,42 +90,42 @@ struct multiboot_info {
>      } u;
>
>      /* Valid if flags sets MBI_MEMMAP */
> -    u32 mmap_length;
> -    u32 mmap_addr;
> +    uint32_t mmap_length;
> +    uint32_t mmap_addr;
>
>      /* Valid if flags sets MBI_DRIVES */
> -    u32 drives_length;
> -    u32 drives_addr;
> +    uint32_t drives_length;
> +    uint32_t drives_addr;
>
>      /* Valid if flags sets MBI_BIOSCONFIG */
> -    u32 config_table;
> +    uint32_t config_table;
>
>      /* Valid if flags sets MBI_LOADERNAME */
> -    u32 boot_loader_name;
> +    uint32_t boot_loader_name;
>
>      /* Valid if flags sets MBI_APM */
> -    u32 apm_table;
> +    uint32_t apm_table;
>  };
>  typedef struct multiboot_info multiboot_info_t;
>
>  /* The module structure.  */
>  struct module {
> -    u32 mod_start;
> -    u32 mod_end;
> -    u32 string;
> -    u32 reserved;
> +    uint32_t mod_start;
> +    uint32_t mod_end;
> +    uint32_t string;
> +    uint32_t reserved;
>  };
>  typedef struct module module_t;
>
>  /* The memory map. Be careful that the offset 0 is base_addr_low
>     but no size.  */
>  struct memory_map {
> -    u32 size;
> -    u32 base_addr_low;
> -    u32 base_addr_high;
> -    u32 length_low;
> -    u32 length_high;
> -    u32 type;
> +    uint32_t size;
> +    uint32_t base_addr_low;
> +    uint32_t base_addr_high;
> +    uint32_t length_low;
> +    uint32_t length_high;
> +    uint32_t type;
>  };
>  typedef struct memory_map memory_map_t;
>
> diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h
> index 7cda620eec8a..f96f5d4c3169 100644
> --- a/xen/include/xen/multiboot2.h
> +++ b/xen/include/xen/multiboot2.h
> @@ -114,6 +114,9 @@
>  #define MULTIBOOT2_FRAMEBUFFER_TYPE_EGA_TEXT            2
>
>  #ifndef __ASSEMBLY__
> +
> +#include <xen/types.h>
> +
>  typedef struct {
>      uint32_t total_size;
>      uint32_t reserved;

Reviewed-by: Frediano Ziglio <frediano.ziglio@cloud.com>

Frediano
Re: [PATCH] xen/multiboot: Make headers be standalone
Posted by Jason Andryuk 1 week ago
On 2024-11-13 13:51, Andrew Cooper wrote:
> Both require xen/types.h.
> 
> Change multiboot.h to include const.h by it's more normal path, and swap u32
> for uint32_t.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>