move KB() etc to make it usable by x86'es mkelf32
cover move KB() etc to make it usable by x86'es mkelf32
mkelf32.c doesn't want to include config.h; if anything, it would probably be autoconf.h which it might include if so needed.
1: include: move KB() etc to macros.h
2: x86/mkelf32: use xen/macros.h
Jan
PATCH 1/2 include: move KB() etc to macros.h
Allow them to be used by build tools which don't include config.h. (They also don't really fit into config.h, as there's nothing "configuration" related about them.)
xen/arch/x86/efi/relocs-dummy.S +1 -0
@@ -1,3 +1,4 @@ +#include <xen/macros.h> .section .reloc, "a", @progbits .balign 4
xen/include/xen/config.h +0 -4
@@ -82,10 +82,6 @@#define __force#define __bitwise -#define KB (_kb) (_AC(_kb, ULL) << 10) -#define MB (_mb) (_AC(_mb, ULL) << 20) -#define GB (_gb) (_AC(_gb, ULL) << 30) -/* allow existing code to work with Kconfig variable */ #define NR_CPUS CONFIG_NR_CPUS
xen/include/xen/macros.h +4 -0
@@ -38,6 +38,10 @@#define __STR (...) #__VA_ARGS__#define STR (...) __STR(__VA_ARGS__) +#define KB (_kb) (_AC(_kb, ULL) << 10) +#define MB (_mb) (_AC(_mb, ULL) << 20) +#define GB (_gb) (_AC(_gb, ULL) << 30) +#ifndef __ASSEMBLER__/* Force a compilation error if condition is true */
PATCH 2/2 x86/mkelf32: use xen/macros.h
In reply to Jan BeulichAvoid open-coding macros we have readily available. Being able to use MB() there might have avoided the flaw corrected by 5416c455f656 ("x86/mkelf32:
Actually pad load segment to 2 MiB boundary").
xen/arch/x86/boot/mkelf32.c +3 -1
@@ -17,7 +17,9 @@#include <unistd.h> #include <inttypes.h> +#include "../../../include/xen/const.h" #include "../../../include/xen/elfstructs.h" +#include "../../../include/xen/macros.h" #define DYNAMICALLY_FILLED 0#define RAW_OFFSET 128
@@ -345,7 +347,7 @@ int main(int argc, char **argv)* the Xen image using 2M pages. To avoid running into adjacent non-RAM * regions, pad the segment to the next 2M boundary. */ - mem_siz = ((uint32_t )in64_phdr.p_memsz + (1U <<21 ) -1 ) & (-1U <<21 ); + mem_siz =ROUNDUP ((uint32_t )in64_phdr.p_memsz,MB (2 )); note_sz = note_base = offset =0 ;if ( num_phdrs >1 )
Quoted 5 lines · Jan Beulich
mkelf32.cdoesn't want to includeconfig.h; if anything, it would probably beautoconf.hwhich it might include if so needed.1: include: move
KB()etc tomacros.h
2: x86/mkelf32: usexen/macros.h
Ah yes, I've been wanting to move them out of config.h for a while.