kexec: add _ALIGN* marcos for align operation
Subsystems (2)
PATCH 1/13 kexec: add _ALIGN* marcos for align operation
From: Zhang Yanfei <[email protected]>
This patch imports Macros for align operation:
- _ALIGN_UP(addr, size): align addr up on a size boundary
- _ALIGN_DOWN(addr, size): align addr down on a size boundary
- _ALIGN(addr, size): align addr up on a size boundary
--- kexec/kexec.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
kexec/kexec.h +12 -0
@@ -100,6 +100,18 @@ do { \ } \ } while(0) +#define _ALIGN_UP_MASK (addr, mask) (((addr) + (mask)) & ~(mask)) +#define _ALIGN_DOWN_MASK (addr, mask) ((addr) & ~(mask)) + +/* align addr on a size boundary - adjust address up/down if needed */ +#define _ALIGN_UP (addr, size) \ + _ALIGN_UP_MASK(addr, (typeof(addr))(size) - 1) +#define _ALIGN_DOWN (addr, size) \ + _ALIGN_DOWN_MASK(addr, (typeof(addr))(size) - 1) + +/* align addr on a size boundary - adjust address up if needed */ +#define _ALIGN (addr, size) _ALIGN_UP(addr, size) +extern unsigned long long mem_min, mem_max;extern int kexec_debug;
Signature · 6 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/13 kexec: use _ALIGN() instead of align()
From: Zhang Yanfei <[email protected]>
Since we have imported macro _ALIGN() for global use, replace the call of function align() with _ALIGN() and remove align().
--- kexec/kexec-elf-boot.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
kexec/kexec-elf-boot.c +1 -7
@@ -67,12 +67,6 @@ static struct boot_notes { }, }; -static inline unsigned long align (unsigned long val,unsigned long align) -{ -return (val + align -1 ) & ~(align -1 ); - -} -unsigned long elf_boot_notes (struct kexec_info *info,unsigned long max_addr,const char *cmdline,int cmdline_len)
@@ -80,7 +74,7 @@ unsigned long elf_boot_notes(unsigned long note_bytes;unsigned long note_base;struct boot_notes *notes; - note_bytes =sizeof (*notes) +align (cmdline_len,4 ); + note_bytes =sizeof (*notes) +_ALIGN (cmdline_len,4 ); notes =xmalloc (note_bytes);memcpy (notes, &boot_notes,sizeof (boot_notes));memcpy (notes->command_line, cmdline, cmdline_len);
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 3/13 kexec: ppc: remove duplicated _ALIGN_* macros
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
We have defined the global align macros for use, so remove the duplicated macros here.
And in file kexec/arch/ppc/include/page.h, we directly expand the align operation for marco PAGE_ALIGN since we have removed marco _ALIGN in this file.
--- kexec/arch/ppc/include/page.h | 9 +-------- kexec/arch/ppc64/crashdump-ppc64.h | 2 -- 2 files changed, 1 insertions(+), 10 deletions(-)
kexec/arch/ppc/include/page.h +1 -8
@@ -21,14 +21,7 @@#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)#define PAGE_MASK (~(PAGE_SIZE-1)) -/* align addr on a size boundary - adjust address up/down if needed */ -#define _ALIGN_UP (addr,size) (((addr)+((size)-1))&(~((size)-1))) -#define _ALIGN_DOWN (addr,size) ((addr)&(~((size)-1))) - -/* align addr on a size boundary - adjust address up if needed */ -#define _ALIGN (addr,size) _ALIGN_UP(addr,size) -/* to align the pointer to the (next) page boundary */ -#define PAGE_ALIGN (addr) _ALIGN(addr, PAGE_SIZE) +#define PAGE_ALIGN (addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))#endif /* _PPC_BOOT_PAGE_H */
kexec/arch/ppc64/crashdump-ppc64.h +0 -2
@@ -20,8 +20,6 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size);#define BACKUP_SRC_SIZE (BACKUP_SRC_END - BACKUP_SRC_START + 1)#define KDUMP_BACKUP_LIMIT BACKUP_SRC_SIZE -#define _ALIGN_UP (addr,size) (((addr)+((size)-1))&(~((size)-1))) -#define _ALIGN_DOWN (addr,size) ((addr)&(~((size)-1)))#define KERNEL_RUN_AT_ZERO_MAGIC 0x72756e30/* "run0" */
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 4/13 kexec: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
--- kexec/crashdump-elf.c | 3 +-- kexec/fs2dt.c | 5 ++--- kexec/kexec-elf-boot.c | 2 +- kexec/kexec-elf-rel.c | 8 ++++---- kexec/kexec-elf.c | 8 ++++---- kexec/kexec.c | 15 +++++++-------- kexec/libfdt/libfdt_internal.h | 2 +- 7 files changed, 20 insertions(+), 23 deletions(-)
kexec/crashdump-elf.c +1 -2
@@ -96,8 +96,7 @@ int FUNC(struct kexec_info *info,return -1 ; } - sz += align -1 ; - sz &= ~(align -1 ); + sz =_ALIGN (sz, align); bufp =xmalloc (sz);memset (bufp,0 , sz);
kexec/fs2dt.c +2 -3
@@ -697,8 +697,7 @@ static void add_boot_block(char **bufp, off_t *sizep)unsigned long tlen, toff;char *buf; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap =cpu_to_be32 (len);
@@ -721,7 +720,7 @@ static void add_boot_block(char **bufp, off_t *sizep) len =propnum ("" ); bb->dt_strings_size =cpu_to_be32 (len); - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize =cpu_to_be32 (be32_to_cpu (bb->off_dt_strings) + len); bb->magic =cpu_to_be32 (0xd00dfeed );
kexec/kexec-elf-boot.c +1 -1
@@ -31,7 +31,7 @@#include "kexec-elf-boot.h" -#define UPSZ (X ) ((sizeof(X) + 3) &~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr;
kexec/kexec-elf-rel.c +4 -4
@@ -225,7 +225,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, buf_align = align; }/* Now align bufsz */ - bufsz = (bufsz + (align -1 )) & ~(align -1 ); + bufsz =_ALIGN (bufsz, align);/* And now add our buffer */ bufsz += shdr->sh_size; }
@@ -237,7 +237,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, bss_align = align; }/* Now align bsssz */ - bsssz = (bsssz + (align -1 )) & ~(align -1 ); + bsssz =_ALIGN (bsssz, align);/* And now add our buffer */ bsssz += shdr->sh_size; }
@@ -269,7 +269,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,if (shdr->sh_type !=SHT_NOBITS ) {unsigned long off;/* Adjust the address */ - data_addr = (data_addr + (align -1 )) & ~(align -1 ); + data_addr =_ALIGN (data_addr, align);/* Update the section */ off = data_addr - buf_addr;
@@ -281,7 +281,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, data_addr += shdr->sh_size; }else {/* Adjust the address */ - bss_addr = (bss_addr + (align -1 )) & ~(align -1 ); + bss_addr =_ALIGN (bss_addr, align);/* Update the section */ shdr->sh_addr = bss_addr;
kexec/kexec-elf.c +4 -4
@@ -704,8 +704,8 @@ static int build_mem_notes(struct mem_ehdr *ehdr)ElfNN_Nhdr hdr;read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); - note_size += (hdr.n_namesz +3 ) & ~3 ; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); + note_size +=_ALIGN (hdr.n_descsz,4 ); ehdr->e_notenum +=1 ; }/* Now walk and normalize the notes */
@@ -716,9 +716,9 @@ static int build_mem_notes(struct mem_ehdr *ehdr)read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); name = note + note_size; - note_size += (hdr.n_namesz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); desc = note + note_size; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_descsz,4 );if ((hdr.n_namesz !=0 ) && (name[hdr.n_namesz -1 ] !='\0' )) {/* If note name string is not null terminated, just
kexec/kexec.c +7 -8
@@ -257,8 +257,7 @@ unsigned long locate_hole(struct kexec_info *info,if (start < hole_min) { start = hole_min; } - start = (start + hole_align -1 ) & - ~((unsigned long long )hole_align -1 ); + start =_ALIGN (start, hole_align);if (end > mem_max) { end = mem_max; }
@@ -276,8 +275,8 @@ unsigned long locate_hole(struct kexec_info *info, hole_base = start;break ; }else { - hole_base = (end - hole_size) & - ~((unsigned long long )hole_align -1 ); + hole_base =_ALIGN_DOWN (end - hole_size, + hole_align); } } }
@@ -313,7 +312,7 @@ void add_segment_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize);/* Verify base is pagesize aligned. * Finding a way to cope with this problem
@@ -363,7 +362,7 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize); base =locate_hole (info, memsz, buf_align, buf_min, buf_max, buf_end);if (base ==ULONG_MAX ) {
@@ -457,8 +456,8 @@ int add_backup_segments(struct kexec_info *info, unsigned long backup_base,return -1 ;if (!find_segment_hole (info, &bkseg_base, &bkseg_size))break ; - start = (bkseg_base + pagesize -1 ) & ~(pagesize -1 ); - end = (bkseg_base + bkseg_size) & ~(pagesize -1 ); + start =_ALIGN (bkseg_base, pagesize); + end =_ALIGN_DOWN (bkseg_base + bkseg_size, pagesize);add_segment_phys_virt (info,NULL ,0 , start, end-start,0 ); mem_size = mem_base + mem_size - \
kexec/libfdt/libfdt_internal.h +1 -1
@@ -52,7 +52,7 @@*/ #include <fdt.h> -#define FDT_ALIGN (x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define FDT_ALIGN (x, a) _ALIGN(x, a)#define FDT_TAGALIGN (x) (FDT_ALIGN((x), FDT_TAGSIZE))#define FDT_CHECK_HEADER (fdt) \
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 5/13 kexec: i386: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
--- kexec/arch/i386/crashdump-x86.c | 6 +++--- kexec/arch/i386/kexec-bzImage.c | 2 +- kexec/arch/i386/kexec-multiboot-x86.c | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-)
kexec/arch/i386/crashdump-x86.c +3 -3
@@ -163,11 +163,11 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),/* Look for kernel text mapping header. */ if ((saddr >= X86_64__START_KERNEL_map) && (eaddr <= X86_64__START_KERNEL_map +X86_64_KERNEL_TEXT_SIZE )) { - saddr = (saddr) & (~(X86_64_KERN_VADDR_ALIGN -1 )); + saddr =_ALIGN_DOWN (saddr,X86_64_KERN_VADDR_ALIGN ); elf_info->kern_vaddr_start = saddr; size = eaddr - saddr;/* Align size to page size boundary. */ - size = (size + align -1 ) & (~(align -1 )); + size =_ALIGN (size, align); elf_info->kern_size = size;dbgprintf ("kernel vaddr = 0x%llx size = 0x%llx\n" , saddr, size);
@@ -1035,7 +1035,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,/* Create a backup region segment to store backup data*/ if (!(info->kexec_flags &KEXEC_PRESERVE_CONTEXT )) { - sz = (info->backup_src_size + align) & ~(align -1 ); + sz =_ALIGN (info->backup_src_size, align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,
kexec/arch/i386/kexec-bzImage.c +1 -1
@@ -223,7 +223,7 @@ int do_bzImage_load(struct kexec_info *info,if (kern16_size_needed >0xfffc )die ("kern16_size_needed is more then 64k\n" ); heap_size =0xfffc - kern16_size_needed;/* less 64k */ - heap_size &= ~(0x200 -1 ); + heap_size =_ALIGN_DOWN (heap_size,0x200 ); kern16_size_needed += heap_size; }else { kern16_size_needed = kern16_size;
kexec/arch/i386/kexec-multiboot-x86.c +2 -3
@@ -230,9 +230,8 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,* module command lines * ============== */ - mbi_bytes = (sizeof (*mbi) + command_line_len - +strlen (BOOTLOADER " " BOOTLOADER_VERSION ) +1 - +3 ) & ~3 ; + mbi_bytes =_ALIGN (sizeof (*mbi) + command_line_len + +strlen (BOOTLOADER " " BOOTLOADER_VERSION ) +1 ,4 ); mbi_buf =xmalloc (mbi_bytes); mbi = mbi_buf;memset (mbi,0 ,sizeof (*mbi));
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 6/13 kexec: arm: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
--- kexec/arch/arm/kexec-zImage-arm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kexec/arch/arm/kexec-zImage-arm.c +1 -1
@@ -414,7 +414,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,* align it. */ dtb_offset = initrd_base + initrd_size +getpagesize (); - dtb_offset &= ~(getpagesize () -1 ); + dtb_offset =_ALIGN_DOWN (dtb_offset,getpagesize ());add_segment (info, dtb_buf, dtb_length, dtb_offset, dtb_length);
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 7/13 kexec: ia64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be simplified.
--- kexec/arch/ia64/crashdump-ia64.c | 6 +++--- kexec/arch/ia64/kexec-elf-ia64.c | 2 +- kexec/arch/ia64/kexec-ia64.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
kexec/arch/ia64/crashdump-ia64.c +3 -3
@@ -83,7 +83,7 @@ static void add_loaded_segments_info(struct mem_ehdr *ehdr) } loaded_segments[loaded_segments_num].start = - phdr->p_paddr & ~(ELF_PAGE_SIZE -1 ); +_ALIGN_DOWN (phdr->p_paddr,ELF_PAGE_SIZE ); loaded_segments[loaded_segments_num].end = loaded_segments[loaded_segments_num].start;
@@ -97,8 +97,8 @@ static void add_loaded_segments_info(struct mem_ehdr *ehdr)if (phdr->p_type !=PT_LOAD )break ; loaded_segments[loaded_segments_num].end = - (phdr->p_paddr + phdr->p_memsz + -ELF_PAGE_SIZE -1 ) & ~(ELF_PAGE_SIZE -1 ); +_ALIGN (phdr->p_paddr + phdr->p_memsz, +ELF_PAGE_SIZE ); i++; } loaded_segments_num++;
kexec/arch/ia64/kexec-elf-ia64.c +1 -1
@@ -264,7 +264,7 @@ int elf_ia64_load(int argc, char **argv, const char *buf, off_t len,strcat (cmdline, buf); } - command_line_len = (command_line_len +15 )&(~15 ); + command_line_len =_ALIGN (command_line_len,16 ); command_line_base = add_buffer(info, cmdline, command_line_len, command_line_len, getpagesize(), 0UL,
kexec/arch/ia64/kexec-ia64.c +3 -3
@@ -50,8 +50,8 @@ static int split_range(int range, unsigned long start, unsigned long end)unsigned int type = memory_range[range -1 ].type;int i;//align end and start to page size of EFI - start = start & ~((1UL <<12 ) -1 ); - end = (end + (1UL <<12 ) -1 )& ~((1UL <<12 ) -1 ); + start =_ALIGN_DOWN (start,1UL <<12 ); + end =_ALIGN (end,1UL <<12 );for (i =0 ; i < range; i++)if (memory_range[i].start <= start && memory_range[i].end >=end)break ;
@@ -230,7 +230,7 @@ int update_loaded_segments(struct mem_ehdr *ehdr)for (i =0 ; i < memory_ranges; i++) {if (memory_range[i].type !=RANGE_RAM )continue ; - start = (memory_range[i].start + align -1 ) & ~(align -1 ); + start =_ALIGN (memory_range[i].start, align); end = memory_range[i].end;if (end > start && (end - start) > (end_addr - start_addr)) {move_loaded_segments (ehdr, start);
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 8/13 kexec: mips: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
--- kexec/arch/mips/crashdump-mips.c | 2 +- kexec/arch/mips/kexec-elf-mips.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kexec/arch/mips/crashdump-mips.c +1 -1
@@ -373,7 +373,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, info->backup_src_start =BACKUP_SRC_START ; info->backup_src_size =BACKUP_SRC_SIZE ;/* Create a backup region segment to store backup data*/ - sz = (BACKUP_SRC_SIZE + align -1 ) & ~(align -1 ); + sz =_ALIGN (BACKUP_SRC_SIZE , align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,
kexec/arch/mips/kexec-elf-mips.c +1 -1
@@ -34,7 +34,7 @@ static const int probe_debug = 0;#define BOOTLOADER "kexec"#define MAX_COMMAND_LINE 256 -#define UPSZ (X ) ((sizeof(X) + 3) & ~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4)static char cmdline_buf[256 ] ="kexec " ;int elf_mips_probe (const char *buf,off_t len)
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 9/13 kexec: ppc: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Besides, remove the duplicate _ALIGN_* definition in file kexec/arch/ppc/crashdump-powerpc.h.
--- kexec/arch/ppc/crashdump-powerpc.c | 2 +- kexec/arch/ppc/crashdump-powerpc.h | 2 -- kexec/arch/ppc/fs2dt.c | 5 ++--- kexec/arch/ppc/kexec-dol-ppc.c | 10 +++++----- kexec/arch/ppc/kexec-elf-ppc.c | 8 ++++---- 5 files changed, 12 insertions(+), 15 deletions(-)
kexec/arch/ppc/crashdump-powerpc.c +1 -1
@@ -329,7 +329,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline, info->backup_src_size =BACKUP_SRC_SIZE ;#ifndef CONFIG_BOOKE /* Create a backup region segment to store backup data*/ - sz = (BACKUP_SRC_SIZE + align -1 ) & ~(align -1 ); + sz =_ALIGN (BACKUP_SRC_SIZE , align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,
kexec/arch/ppc/crashdump-powerpc.h +0 -2
@@ -35,8 +35,6 @@ extern struct arch_options_t arch_options;#endif #define KDUMP_BACKUP_LIMIT BACKUP_SRC_SIZE -#define _ALIGN_UP (addr, size) (((addr)+((size)-1))&(~((size)-1))) -#define _ALIGN_DOWN (addr, size) ((addr)&(~((size)-1)))extern unsigned long long crash_base;extern unsigned long long crash_size;
kexec/arch/ppc/fs2dt.c +2 -3
@@ -407,8 +407,7 @@ int create_flatten_tree(struct kexec_info *info, unsigned char **bufp,putnode (); *dt++ =9 ; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap = len;
@@ -426,7 +425,7 @@ int create_flatten_tree(struct kexec_info *info, unsigned char **bufp, len =propnum ("" ); bb->dt_strings_size = len; - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize = bb->off_dt_strings + len; bb->magic =0xd00dfeed ;
kexec/arch/ppc/kexec-dol-ppc.c +5 -5
@@ -87,11 +87,11 @@ typedef struct {#define PAGE_SHIFT 12#define PAGE_SIZE (1UL << PAGE_SHIFT)#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1)) -#define PAGE_ALIGN (addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) +#define PAGE_ALIGN (addr) _ALIGN(addr, PAGE_SIZE)#define MAX_COMMAND_LINE 256 -#define UPSZ (X ) ((sizeof(X) + 3) & ~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr; Elf_Nhdr bl_hdr;
@@ -442,14 +442,14 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len), }/* build the setup glue and argument segment (segment 0) */ - note_bytes =sizeof (elf_boot_notes) + ((command_line_len +3 ) & ~3 ); - arg_bytes = note_bytes + ((setup_dol_size +3 ) & ~3 ); + note_bytes =sizeof (elf_boot_notes) +_ALIGN (command_line_len,4 ); + arg_bytes = note_bytes +_ALIGN (setup_dol_size,4 ); arg_buf =xmalloc (arg_bytes); arg_base =add_buffer (info, arg_buf, arg_bytes, arg_bytes,4 ,0 ,0xFFFFFFFFUL ,1 ); - notes = (struct boot_notes *)(arg_buf + ((setup_dol_size +3 ) & ~3 )); + notes = (struct boot_notes *)(arg_buf +_ALIGN (setup_dol_size,4 )); notes->hdr.b_size = note_bytes; notes->cmd_hdr.n_descsz = command_line_len;
kexec/arch/ppc/kexec-elf-ppc.c +4 -4
@@ -37,7 +37,7 @@ const char *ramdisk;int create_flatten_tree (struct kexec_info *,unsigned char **,unsigned long *,char *); -#define UPSZ (X ) ((sizeof(X) + 3) & ~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4); #ifdef WITH_GAMECUBE static struct boot_notes { Elf_Bhdr hdr;
@@ -327,14 +327,14 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len, setup_size = setup_simple_size; setup_simple_regs.spr8 = ehdr.e_entry;/* Link Register */ } - note_bytes =sizeof (elf_boot_notes) + ((command_line_len +3 ) & ~3 ); - arg_bytes = note_bytes + ((setup_size +3 ) & ~3 ); + note_bytes =sizeof (elf_boot_notes) +_ALIGN (command_line_len,4 ); + arg_bytes = note_bytes +_ALIGN (setup_size,4 ); arg_buf =xmalloc (arg_bytes); arg_base =add_buffer (info, arg_buf, arg_bytes, arg_bytes,4 ,0 ,elf_max_addr (&ehdr),1 ); - notes = (struct boot_notes *)(arg_buf + ((setup_size +3 ) & ~3 )); + notes = (struct boot_notes *)(arg_buf +_ALIGN (setup_size,4 ));memcpy (arg_buf, setup_start, setup_size);memcpy (notes, &elf_boot_notes,sizeof (elf_boot_notes));
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 10/13 kexec: ppc64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
--- kexec/arch/ppc64/crashdump-ppc64.c | 4 ++-- kexec/arch/ppc64/fs2dt.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-)
kexec/arch/ppc64/crashdump-ppc64.c +2 -2
@@ -298,7 +298,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)* to the next page size boundary though, so makedumpfile can * read it safely without going south on us. */ - cend = (cend + page_size -1 ) & (~(page_size -1 )); + cend =_ALIGN (cend, page_size); crash_memory_range[memory_ranges].start = cstart; crash_memory_range[memory_ranges++].end = cend;
@@ -400,7 +400,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, info->backup_src_start =BACKUP_SRC_START ; info->backup_src_size =BACKUP_SRC_SIZE ;/* Create a backup region segment to store backup data*/ - sz = (BACKUP_SRC_SIZE + align -1 ) & ~(align -1 ); + sz =_ALIGN (BACKUP_SRC_SIZE , align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,
kexec/arch/ppc64/fs2dt.c +2 -4
@@ -698,8 +698,7 @@ int create_flatten_tree(char **bufp, off_t *sizep, char *cmdline)dt_reserve (&dt,1 ); *dt++ =9 ; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap = len;
@@ -714,8 +713,7 @@ int create_flatten_tree(char **bufp, off_t *sizep, char *cmdline) len *=sizeof (unsigned ); bb->off_dt_strings = bb->off_dt_struct + len; - len =propnum ("" ); - len +=3 ; len &= ~3 ; + len =_ALIGN (propnum ("" ),4 ); bb->totalsize = bb->off_dt_strings + len; bb->magic =0xd00dfeed ;
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 11/13 kexec: s390: remove ALIGN_UP and use _ALIGN_UP
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
We have _ALIGN_UP now, so remove ALIGN_UP and use _ALIGN_UP instead of it.
--- kexec/arch/s390/kexec-image.c | 2 +- kexec/arch/s390/kexec-s390.h | 1 - 2 files changed, 1 insertions(+), 2 deletions(-)
kexec/arch/s390/kexec-image.c +1 -1
@@ -112,7 +112,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,return -1 ; } ramdisk_origin =MAX (RAMDISK_ORIGIN_ADDR , kernel_size); - ramdisk_origin =ALIGN_UP (ramdisk_origin,0x100000 ); + ramdisk_origin =_ALIGN_UP (ramdisk_origin,0x100000 );add_segment_check (info, rd_buffer, ramdisk_len, ramdisk_origin, ramdisk_len); }
kexec/arch/s390/kexec-s390.h +0 -1
@@ -21,7 +21,6 @@#define COMMAND_LINESIZE 896#define MAX_MEMORY_RANGES 1024 -#define ALIGN_UP (addr, size) (((addr) + ((size)-1)) & (~((size)-1)))#define MAX (x, y) ((x) > (y) ? (x) : (y))#define MIN (x, y) ((x) < (y) ? (x) : (y))
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 12/13 kexec: sh: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
--- kexec/arch/sh/kexec-netbsd-sh.c | 4 ++-- kexec/arch/sh/kexec-zImage-sh.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
kexec/arch/sh/kexec-netbsd-sh.c +2 -2
@@ -121,7 +121,7 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t UNUSED(len), size = bbs; } - size = (size + psz -1 ) & ~(psz -1 ); + size =_ALIGN (size, psz);memset (&img[bbs],0 , size-bbs);add_segment (info, img, size, start, size); start += size;
@@ -132,7 +132,7 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t UNUSED(len),if (miniroot) { miniroot_buf =slurp_file (miniroot, &miniroot_length); howto_value |=0x200 ; - size = (miniroot_length + psz -1 ) & ~(psz -1 ); + size =_ALIGN (miniroot_length, psz);add_segment (info, miniroot_buf, size, start, size); start += size; }
kexec/arch/sh/kexec-zImage-sh.c +1 -1
@@ -138,7 +138,7 @@ int zImage_sh_load(int argc, char **argv, const char *buf, off_t len,* the zImage will relocate itself, but only up seems supported. */ - image_base = (empty_zero + (0x10000 -1 )) & ~(0x10000 -1 ); + image_base =_ALIGN (empty_zero,0x10000 );add_segment (info, buf, len, image_base, len); info->entry = (void *)virt_to_phys (image_base);return 0 ;
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 13/13 kexec: x86_64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
--- kexec/arch/x86_64/kexec-bzImage64.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kexec/arch/x86_64/kexec-bzImage64.c +1 -1
@@ -197,7 +197,7 @@ static int do_bzImage64_load(struct kexec_info *info, k_size = kernel_len - kern16_size;/* need to use run-time size for buffer searching */ dbgprintf ("kernel init_size 0x%x\n" , real_mode->init_size); - size = (real_mode->init_size + (4096 -1 )) & ~(4096 -1 ); + size =_ALIGN (real_mode->init_size,4096 ); align = real_mode->kernel_alignment; addr =add_buffer (info, kernel + kern16_size, k_size, size, align,0x100000 ,-1 ,-1 );
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 04/13] kexec: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
Not a big deal, but I believe this patch needs to come after the arm changes in the series in order to avoid breaking the build on that architecture.
Quoted 199 lines
Signed-off-by Zhang Yanfei <[email protected]>--- kexec/crashdump-elf.c | 3 +-- kexec/fs2dt.c | 5 ++--- kexec/kexec-elf-boot.c | 2 +- kexec/kexec-elf-rel.c | 8 ++++---- kexec/kexec-elf.c | 8 ++++---- kexec/kexec.c | 15 +++++++-------- kexec/libfdt/libfdt_internal.h | 2 +- 7 files changed, 20 insertions(+), 23 deletions(-)kexec/crashdump-elf.c +1
-2@@ -96,8 +96,7 @@ int FUNC(struct kexec_info *info,return -1 ; } - sz += align -1 ; - sz &= ~(align -1 ); + sz =_ALIGN (sz, align); bufp =xmalloc (sz);memset (bufp,0 , sz);kexec/fs2dt.c +2
-3@@ -697,8 +697,7 @@ static void add_boot_block(char **bufp, off_t *sizep)unsigned long tlen, toff;char *buf; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap =cpu_to_be32 (len);@@ -721,7 +720,7 @@ static void add_boot_block(char **bufp, off_t *sizep) len =propnum ("" ); bb->dt_strings_size =cpu_to_be32 (len); - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize =cpu_to_be32 (be32_to_cpu (bb->off_dt_strings) + len); bb->magic =cpu_to_be32 (0xd00dfeed );kexec/kexec-elf-boot.c +1
-1@@ -31,7 +31,7 @@#include "kexec-elf-boot.h" -#define UPSZ (X ) ((sizeof(X) + 3) &~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr;kexec/kexec-elf-rel.c +4
-4@@ -225,7 +225,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, buf_align = align; }/* Now align bufsz */ - bufsz = (bufsz + (align -1 )) & ~(align -1 ); + bufsz =_ALIGN (bufsz, align);/* And now add our buffer */ bufsz += shdr->sh_size; }@@ -237,7 +237,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, bss_align = align; }/* Now align bsssz */ - bsssz = (bsssz + (align -1 )) & ~(align -1 ); + bsssz =_ALIGN (bsssz, align);/* And now add our buffer */ bsssz += shdr->sh_size; }@@ -269,7 +269,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,if (shdr->sh_type !=SHT_NOBITS ) {unsigned long off;/* Adjust the address */ - data_addr = (data_addr + (align -1 )) & ~(align -1 ); + data_addr =_ALIGN (data_addr, align);/* Update the section */ off = data_addr - buf_addr;@@ -281,7 +281,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, data_addr += shdr->sh_size; }else {/* Adjust the address */ - bss_addr = (bss_addr + (align -1 )) & ~(align -1 ); + bss_addr =_ALIGN (bss_addr, align);/* Update the section */ shdr->sh_addr = bss_addr;kexec/kexec-elf.c +4
-4@@ -704,8 +704,8 @@ static int build_mem_notes(struct mem_ehdr *ehdr)ElfNN_Nhdr hdr;read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); - note_size += (hdr.n_namesz +3 ) & ~3 ; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); + note_size +=_ALIGN (hdr.n_descsz,4 ); ehdr->e_notenum +=1 ; }/* Now walk and normalize the notes */ @@ -716,9 +716,9 @@ static int build_mem_notes(struct mem_ehdr *ehdr)read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); name = note + note_size; - note_size += (hdr.n_namesz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); desc = note + note_size; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_descsz,4 );if ((hdr.n_namesz !=0 ) && (name[hdr.n_namesz -1 ] !='\0' )) {/* If note name string is not null terminated, just kexec/kexec.c +7
-8@@ -257,8 +257,7 @@ unsigned long locate_hole(struct kexec_info *info,if (start < hole_min) { start = hole_min; } - start = (start + hole_align -1 ) & - ~((unsigned long long )hole_align -1 ); + start =_ALIGN (start, hole_align);if (end > mem_max) { end = mem_max; }@@ -276,8 +275,8 @@ unsigned long locate_hole(struct kexec_info *info, hole_base = start;break ; }else { - hole_base = (end - hole_size) & - ~((unsigned long long )hole_align -1 ); + hole_base =_ALIGN_DOWN (end - hole_size, + hole_align); } } }@@ -313,7 +312,7 @@ void add_segment_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize);/* Verify base is pagesize aligned. * Finding a way to cope with this problem @@ -363,7 +362,7 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize); base =locate_hole (info, memsz, buf_align, buf_min, buf_max, buf_end);if (base ==ULONG_MAX ) {@@ -457,8 +456,8 @@ int add_backup_segments(struct kexec_info *info, unsigned long backup_base,return -1 ;if (!find_segment_hole (info, &bkseg_base, &bkseg_size))break ; - start = (bkseg_base + pagesize -1 ) & ~(pagesize -1 ); - end = (bkseg_base + bkseg_size) & ~(pagesize -1 ); + start =_ALIGN (bkseg_base, pagesize); + end =_ALIGN_DOWN (bkseg_base + bkseg_size, pagesize);add_segment_phys_virt (info,NULL ,0 , start, end-start,0 ); mem_size = mem_base + mem_size - \kexec/libfdt/libfdt_internal.h +1
-1@@ -52,7 +52,7 @@*/ #include <fdt.h> -#define FDT_ALIGN (x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define FDT_ALIGN (x, a) _ALIGN(x, a)#define FDT_TAGALIGN (x) (FDT_ALIGN((x), FDT_TAGSIZE))#define FDT_CHECK_HEADER (fdt) \Signature · 1 line
1.7.1
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 09/13] kexec: ppc: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 7 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Besides, remove the duplicate _ALIGN_* definition in file
kexec/arch/ppc/crashdump-powerpc.h.
This appears to break the build on ppc.
powerpc-linux-gnu-gcc -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -I/include -I./include -I./util_lib/include -Iinclude/ -I./kexec/libfdt -I./kexec/arch/ppc/include -c -MD -o kexec/arch/ppc/fs2dt.o kexec/arch/ppc/fs2dt.c kexec/arch/ppc/fs2dt.c: In function 'add_usable_mem_property':kexec/arch/ppc/fs2dt.c:146: warning: comparison between signed and unsigned integer expressionskexec/arch/ppc/fs2dt.c:128: warning: unused variable 'buf'kexec/arch/ppc/fs2dt.c:125: warning: unused parameter 'len'kexec/arch/ppc/fs2dt.c: In function 'putnode':kexec/arch/ppc/fs2dt.c:326: warning: passing argument 4 of 'scandir' from incompatible pointer type/usr/powerpc-linux-gnu/include/dirent.h:252: note: expected 'int (*)(const struct dirent **, const struct dirent **)' but argument is of type 'int (*)(const void *, const void *)'kexec/arch/ppc/fs2dt.c:449:1: error: unterminated argument list invoking macro "_ALIGN"kexec/arch/ppc/fs2dt.c: In function 'create_flatten_tree':kexec/arch/ppc/fs2dt.c:410: error: '_ALIGN' undeclared (first use in this function)kexec/arch/ppc/fs2dt.c:410: error: (Each undeclared identifier is reported only oncekexec/arch/ppc/fs2dt.c:410: error: for each function it appears in.)kexec/arch/ppc/fs2dt.c:410: error: expected ';' at end of inputkexec/arch/ppc/fs2dt.c:410: error: expected declaration or statement at end of inputkexec/arch/ppc/fs2dt.c:395: warning: unused variable 'buf'kexec/arch/ppc/fs2dt.c:394: warning: unused variable 'tlen'kexec/arch/ppc/fs2dt.c:390: warning: unused parameter 'info'kexec/arch/ppc/fs2dt.c:390: warning: unused parameter 'bufp'kexec/arch/ppc/fs2dt.c:391: warning: unused parameter 'sizep'
make: *** [kexec/arch/ppc/fs2dt.o] Error 1
Quoted 129 lines
Signed-off-by Zhang Yanfei <[email protected]>--- kexec/arch/ppc/crashdump-powerpc.c | 2 +- kexec/arch/ppc/crashdump-powerpc.h | 2 -- kexec/arch/ppc/fs2dt.c | 5 ++--- kexec/arch/ppc/kexec-dol-ppc.c | 10 +++++----- kexec/arch/ppc/kexec-elf-ppc.c | 8 ++++---- 5 files changed, 12 insertions(+), 15 deletions(-)kexec/arch/ppc/crashdump-powerpc.c +1
-1@@ -329,7 +329,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline, info->backup_src_size =BACKUP_SRC_SIZE ;#ifndef CONFIG_BOOKE /* Create a backup region segment to store backup data*/ - sz = (BACKUP_SRC_SIZE + align -1 ) & ~(align -1 ); + sz =_ALIGN (BACKUP_SRC_SIZE , align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,kexec/arch/ppc/crashdump-powerpc.h +0
-2@@ -35,8 +35,6 @@ extern struct arch_options_t arch_options;#endif #define KDUMP_BACKUP_LIMIT BACKUP_SRC_SIZE -#define _ALIGN_UP (addr, size) (((addr)+((size)-1))&(~((size)-1))) -#define _ALIGN_DOWN (addr, size) ((addr)&(~((size)-1)))extern unsigned long long crash_base;extern unsigned long long crash_size;kexec/arch/ppc/fs2dt.c +2
-3@@ -407,8 +407,7 @@ int create_flatten_tree(struct kexec_info *info, unsigned char **bufp,putnode (); *dt++ =9 ; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap = len;@@ -426,7 +425,7 @@ int create_flatten_tree(struct kexec_info *info, unsigned char **bufp, len =propnum ("" ); bb->dt_strings_size = len; - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize = bb->off_dt_strings + len; bb->magic =0xd00dfeed ;kexec/arch/ppc/kexec-dol-ppc.c +5
-5@@ -87,11 +87,11 @@ typedef struct {#define PAGE_SHIFT 12#define PAGE_SIZE (1UL << PAGE_SHIFT)#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1)) -#define PAGE_ALIGN (addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) +#define PAGE_ALIGN (addr) _ALIGN(addr, PAGE_SIZE)#define MAX_COMMAND_LINE 256 -#define UPSZ (X ) ((sizeof(X) + 3) & ~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr; Elf_Nhdr bl_hdr;@@ -442,14 +442,14 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len), }/* build the setup glue and argument segment (segment 0) */ - note_bytes =sizeof (elf_boot_notes) + ((command_line_len +3 ) & ~3 ); - arg_bytes = note_bytes + ((setup_dol_size +3 ) & ~3 ); + note_bytes =sizeof (elf_boot_notes) +_ALIGN (command_line_len,4 ); + arg_bytes = note_bytes +_ALIGN (setup_dol_size,4 ); arg_buf =xmalloc (arg_bytes); arg_base =add_buffer (info, arg_buf, arg_bytes, arg_bytes,4 ,0 ,0xFFFFFFFFUL ,1 ); - notes = (struct boot_notes *)(arg_buf + ((setup_dol_size +3 ) & ~3 )); + notes = (struct boot_notes *)(arg_buf +_ALIGN (setup_dol_size,4 )); notes->hdr.b_size = note_bytes; notes->cmd_hdr.n_descsz = command_line_len;kexec/arch/ppc/kexec-elf-ppc.c +4
-4@@ -37,7 +37,7 @@ const char *ramdisk;int create_flatten_tree (struct kexec_info *,unsigned char **,unsigned long *,char *); -#define UPSZ (X ) ((sizeof(X) + 3) & ~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4); #ifdef WITH_GAMECUBE static struct boot_notes { Elf_Bhdr hdr;@@ -327,14 +327,14 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len, setup_size = setup_simple_size; setup_simple_regs.spr8 = ehdr.e_entry;/* Link Register */ } - note_bytes =sizeof (elf_boot_notes) + ((command_line_len +3 ) & ~3 ); - arg_bytes = note_bytes + ((setup_size +3 ) & ~3 ); + note_bytes =sizeof (elf_boot_notes) +_ALIGN (command_line_len,4 ); + arg_bytes = note_bytes +_ALIGN (setup_size,4 ); arg_buf =xmalloc (arg_bytes); arg_base =add_buffer (info, arg_buf, arg_bytes, arg_bytes,4 ,0 ,elf_max_addr (&ehdr),1 ); - notes = (struct boot_notes *)(arg_buf + ((setup_size +3 ) & ~3 )); + notes = (struct boot_notes *)(arg_buf +_ALIGN (setup_size,4 ));memcpy (arg_buf, setup_start, setup_size);memcpy (notes, &elf_boot_notes,sizeof (elf_boot_notes));Signature · 1 line
1.7.1
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 10/13] kexec: ppc64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
This appears to break the ppc64 build.
powerpc64-unknown-linux-gnu-gcc -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -I/home/horms/local/opt/crosstool/powerpc-970/gcc-4.1.1-glibc-2.3.6/powerpc64-unknown-linux-gnu/include -I./include -I./util_lib/include -Iinclude/ -I./kexec/arch/ppc64/include -c -MD -o kexec/arch/ppc64/fs2dt.o kexec/arch/ppc64/fs2dt.c kexec/arch/ppc64/fs2dt.c: In function 'putnode':kexec/arch/ppc64/fs2dt.c:492: warning: passing argument 4 of 'scandir' from
incompatible pointer typekexec/arch/ppc64/fs2dt.c:738:1: error: unterminated argument list invoking
macro "_ALIGN"kexec/arch/ppc64/fs2dt.c: In function 'create_flatten_tree':kexec/arch/ppc64/fs2dt.c:701: error: '_ALIGN' undeclared (first use in this
function)kexec/arch/ppc64/fs2dt.c:701: error: (Each undeclared identifier is
reported only oncekexec/arch/ppc64/fs2dt.c:701: error: for each function it appears in.)kexec/arch/ppc64/fs2dt.c:701: error: expected ';' at end of inputkexec/arch/ppc64/fs2dt.c:676: warning: unused variable 'buf'kexec/arch/ppc64/fs2dt.c:675: warning: unused variable 'tlen'kexec/arch/ppc64/fs2dt.c:672: warning: unused parameter 'bufp'kexec/arch/ppc64/fs2dt.c:672: warning: unused parameter 'sizep'kexec/arch/ppc64/fs2dt.c:701: warning: control reaches end of non-void function
Quoted 55 lines
Signed-off-by Zhang Yanfei <[email protected]>--- kexec/arch/ppc64/crashdump-ppc64.c | 4 ++-- kexec/arch/ppc64/fs2dt.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-)kexec/arch/ppc64/crashdump-ppc64.c +2
-2@@ -298,7 +298,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)* to the next page size boundary though, so makedumpfile can * read it safely without going south on us. */ - cend = (cend + page_size -1 ) & (~(page_size -1 )); + cend =_ALIGN (cend, page_size); crash_memory_range[memory_ranges].start = cstart; crash_memory_range[memory_ranges++].end = cend;@@ -400,7 +400,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, info->backup_src_start =BACKUP_SRC_START ; info->backup_src_size =BACKUP_SRC_SIZE ;/* Create a backup region segment to store backup data*/ - sz = (BACKUP_SRC_SIZE + align -1 ) & ~(align -1 ); + sz =_ALIGN (BACKUP_SRC_SIZE , align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,kexec/arch/ppc64/fs2dt.c +2
-4@@ -698,8 +698,7 @@ int create_flatten_tree(char **bufp, off_t *sizep, char *cmdline)dt_reserve (&dt,1 ); *dt++ =9 ; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap = len;@@ -714,8 +713,7 @@ int create_flatten_tree(char **bufp, off_t *sizep, char *cmdline) len *=sizeof (unsigned ); bb->off_dt_strings = bb->off_dt_struct + len; - len =propnum ("" ); - len +=3 ; len &= ~3 ; + len =_ALIGN (propnum ("" ),4 ); bb->totalsize = bb->off_dt_strings + len; bb->magic =0xd00dfeed ;Signature · 1 line
1.7.1
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 09/13] kexec: ppc: use _ALIGN* to make the logic clear
In reply to Simon HormanQuoted 25 lines · Simon Horman
Quoted 7 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Besides, remove the duplicate _ALIGN_* definition in file
kexec/arch/ppc/crashdump-powerpc.h.This appears to break the build on ppc.
powerpc-linux-gnu-gcc -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -I/include -I./include -I./util_lib/include -Iinclude/ -I./kexec/libfdt -I./kexec/arch/ppc/include -c -MD -o
kexec/arch/ppc/fs2dt.okexec/arch/ppc/fs2dt.ckexec/arch/ppc/fs2dt.c: In function 'add_usable_mem_property':kexec/arch/ppc/fs2dt.c:146: warning: comparison between signed and unsigned integer expressionskexec/arch/ppc/fs2dt.c:128: warning: unused variable 'buf'kexec/arch/ppc/fs2dt.c:125: warning: unused parameter 'len'kexec/arch/ppc/fs2dt.c: In function 'putnode':kexec/arch/ppc/fs2dt.c:326: warning: passing argument 4 of 'scandir' from incompatible pointer type/usr/powerpc-linux-gnu/include/dirent.h:252: note: expected 'int (*)(const struct dirent **, const struct dirent **)' but argument is of type 'int (*)(const void *, const void *)'kexec/arch/ppc/fs2dt.c:449:1: error: unterminated argument list invoking macro "_ALIGN"kexec/arch/ppc/fs2dt.c: In function 'create_flatten_tree':kexec/arch/ppc/fs2dt.c:410: error: '_ALIGN' undeclared (first use in this function)kexec/arch/ppc/fs2dt.c:410: error: (Each undeclared identifier is reported only oncekexec/arch/ppc/fs2dt.c:410: error: for each function it appears in.)
Quoted 10 lines
kexec/arch/ppc/fs2dt.c:410: error: expected ';' at end of inputkexec/arch/ppc/fs2dt.c:410: error: expected declaration or statement at end of inputkexec/arch/ppc/fs2dt.c:395: warning: unused variable 'buf'kexec/arch/ppc/fs2dt.c:394: warning: unused variable 'tlen'kexec/arch/ppc/fs2dt.c:390: warning: unused parameter 'info'kexec/arch/ppc/fs2dt.c:390: warning: unused parameter 'bufp'kexec/arch/ppc/fs2dt.c:391: warning: unused parameter 'sizep'
make: *** [kexec/arch/ppc/fs2dt.o] Error 1Quoted 1 line
Sorry for my carelessness. I forgot a ")" .
I've updated the patch.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v2 9/13 kexec: ppc: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiBy replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Besides, remove the duplicate _ALIGN_* definition in file kexec/arch/ppc/crashdump-powerpc.h.
--- kexec/arch/ppc/crashdump-powerpc.c | 2 +- kexec/arch/ppc/crashdump-powerpc.h | 2 -- kexec/arch/ppc/fs2dt.c | 5 ++--- kexec/arch/ppc/kexec-dol-ppc.c | 10 +++++----- kexec/arch/ppc/kexec-elf-ppc.c | 8 ++++---- 5 files changed, 12 insertions(+), 15 deletions(-)
kexec/arch/ppc/crashdump-powerpc.c +1 -1
@@ -329,7 +329,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline, info->backup_src_size =BACKUP_SRC_SIZE ;#ifndef CONFIG_BOOKE /* Create a backup region segment to store backup data*/ - sz = (BACKUP_SRC_SIZE + align -1 ) & ~(align -1 ); + sz =_ALIGN (BACKUP_SRC_SIZE , align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,
kexec/arch/ppc/crashdump-powerpc.h +0 -2
@@ -35,8 +35,6 @@ extern struct arch_options_t arch_options;#endif #define KDUMP_BACKUP_LIMIT BACKUP_SRC_SIZE -#define _ALIGN_UP (addr, size) (((addr)+((size)-1))&(~((size)-1))) -#define _ALIGN_DOWN (addr, size) ((addr)&(~((size)-1)))extern unsigned long long crash_base;extern unsigned long long crash_size;
kexec/arch/ppc/fs2dt.c +2 -3
@@ -407,8 +407,7 @@ int create_flatten_tree(struct kexec_info *info, unsigned char **bufp,putnode (); *dt++ =9 ; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len =_ALIGN (sizeof (bb[0 ]),8 ); bb->off_mem_rsvmap = len;
@@ -426,7 +425,7 @@ int create_flatten_tree(struct kexec_info *info, unsigned char **bufp, len =propnum ("" ); bb->dt_strings_size = len; - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize = bb->off_dt_strings + len; bb->magic =0xd00dfeed ;
kexec/arch/ppc/kexec-dol-ppc.c +5 -5
@@ -87,11 +87,11 @@ typedef struct {#define PAGE_SHIFT 12#define PAGE_SIZE (1UL << PAGE_SHIFT)#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1)) -#define PAGE_ALIGN (addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) +#define PAGE_ALIGN (addr) _ALIGN(addr, PAGE_SIZE)#define MAX_COMMAND_LINE 256 -#define UPSZ (X ) ((sizeof(X) + 3) & ~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr; Elf_Nhdr bl_hdr;
@@ -442,14 +442,14 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len), }/* build the setup glue and argument segment (segment 0) */ - note_bytes =sizeof (elf_boot_notes) + ((command_line_len +3 ) & ~3 ); - arg_bytes = note_bytes + ((setup_dol_size +3 ) & ~3 ); + note_bytes =sizeof (elf_boot_notes) +_ALIGN (command_line_len,4 ); + arg_bytes = note_bytes +_ALIGN (setup_dol_size,4 ); arg_buf =xmalloc (arg_bytes); arg_base =add_buffer (info, arg_buf, arg_bytes, arg_bytes,4 ,0 ,0xFFFFFFFFUL ,1 ); - notes = (struct boot_notes *)(arg_buf + ((setup_dol_size +3 ) & ~3 )); + notes = (struct boot_notes *)(arg_buf +_ALIGN (setup_dol_size,4 )); notes->hdr.b_size = note_bytes; notes->cmd_hdr.n_descsz = command_line_len;
kexec/arch/ppc/kexec-elf-ppc.c +4 -4
@@ -37,7 +37,7 @@ const char *ramdisk;int create_flatten_tree (struct kexec_info *,unsigned char **,unsigned long *,char *); -#define UPSZ (X ) ((sizeof(X) + 3) & ~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4); #ifdef WITH_GAMECUBE static struct boot_notes { Elf_Bhdr hdr;
@@ -327,14 +327,14 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len, setup_size = setup_simple_size; setup_simple_regs.spr8 = ehdr.e_entry;/* Link Register */ } - note_bytes =sizeof (elf_boot_notes) + ((command_line_len +3 ) & ~3 ); - arg_bytes = note_bytes + ((setup_size +3 ) & ~3 ); + note_bytes =sizeof (elf_boot_notes) +_ALIGN (command_line_len,4 ); + arg_bytes = note_bytes +_ALIGN (setup_size,4 ); arg_buf =xmalloc (arg_bytes); arg_base =add_buffer (info, arg_buf, arg_bytes, arg_bytes,4 ,0 ,elf_max_addr (&ehdr),1 ); - notes = (struct boot_notes *)(arg_buf + ((setup_size +3 ) & ~3 )); + notes = (struct boot_notes *)(arg_buf +_ALIGN (setup_size,4 ));memcpy (arg_buf, setup_start, setup_size);memcpy (notes, &elf_boot_notes,sizeof (elf_boot_notes));
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v2 10/13 kexec: ppc64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiBy replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
--- kexec/arch/ppc64/crashdump-ppc64.c | 4 ++-- kexec/arch/ppc64/fs2dt.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-)
kexec/arch/ppc64/crashdump-ppc64.c +2 -2
@@ -298,7 +298,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)* to the next page size boundary though, so makedumpfile can * read it safely without going south on us. */ - cend = (cend + page_size -1 ) & (~(page_size -1 )); + cend =_ALIGN (cend, page_size); crash_memory_range[memory_ranges].start = cstart; crash_memory_range[memory_ranges++].end = cend;
@@ -400,7 +400,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, info->backup_src_start =BACKUP_SRC_START ; info->backup_src_size =BACKUP_SRC_SIZE ;/* Create a backup region segment to store backup data*/ - sz = (BACKUP_SRC_SIZE + align -1 ) & ~(align -1 ); + sz =_ALIGN (BACKUP_SRC_SIZE , align); tmp =xmalloc (sz);memset (tmp,0 , sz); info->backup_start = add_buffer(info, tmp, sz, sz, align,
kexec/arch/ppc64/fs2dt.c +2 -4
@@ -698,8 +698,7 @@ int create_flatten_tree(char **bufp, off_t *sizep, char *cmdline)dt_reserve (&dt,1 ); *dt++ =9 ; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len =_ALIGN (sizeof (bb[0 ]),8 ); bb->off_mem_rsvmap = len;
@@ -714,8 +713,7 @@ int create_flatten_tree(char **bufp, off_t *sizep, char *cmdline) len *=sizeof (unsigned ); bb->off_dt_strings = bb->off_dt_struct + len; - len =propnum ("" ); - len +=3 ; len &= ~3 ; + len =_ALIGN (propnum ("" ),4 ); bb->totalsize = bb->off_dt_strings + len; bb->magic =0xd00dfeed ;
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedQuoted 8 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
This patch imports Macros for align operation:
-_ALIGN_UP(addr, size): align addr up on a size boundary
-_ALIGN_DOWN(addr, size): align addr down on a size boundary
-_ALIGN(addr, size): align addr up on a size boundarySigned-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 02/13] kexec: use _ALIGN() instead of align()
In reply to Zhang YanfeiQuoted 6 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
Since we have imported macro
_ALIGN()for global use, replace the call of functionalign()with_ALIGN()and removealign().Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 03/13] kexec: ppc: remove duplicated _ALIGN_* macros
In reply to Zhang YanfeiQuoted 10 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
We have defined the global align macros for use, so remove the duplicated macros here.
And in file
kexec/arch/ppc/include/page.h, we directly expand the align operation for marcoPAGE_ALIGNsince we have removed marco_ALIGNin this file.Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 04/13] kexec: use _ALIGN* to make the logic clear
In reply to Simon HormanQuoted 9 lines · Simon Horman
Quoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
Not a big deal, but I believe this patch needs to come after the arm changes in the series in order to avoid breaking the build on that architecture.
I have applied this as the last patch of this series that I have applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 05/13] kexec: i386: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 06/13] kexec: arm: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 04/13] kexec: use _ALIGN* to make the logic clear
In reply to Simon HormanQuoted 9 lines · Simon Horman
Quoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
Not a big deal, but I believe this patch needs to come after the arm changes in the series in order to avoid breaking the build on that architecture.
Sorry, could you explain more? I don't have an arm machine, so, I couldn't test them.
And I found a bug in this patch, still the ")" issue
+ len = _ALIGN(sizeof(bb[0], 8);
oops...
Quoted 196 lines
Quoted 196 lines
Signed-off-by Zhang Yanfei <[email protected]>--- kexec/crashdump-elf.c | 3 +-- kexec/fs2dt.c | 5 ++--- kexec/kexec-elf-boot.c | 2 +- kexec/kexec-elf-rel.c | 8 ++++---- kexec/kexec-elf.c | 8 ++++---- kexec/kexec.c | 15 +++++++-------- kexec/libfdt/libfdt_internal.h | 2 +- 7 files changed, 20 insertions(+), 23 deletions(-)kexec/crashdump-elf.c +1
-2@@ -96,8 +96,7 @@ int FUNC(struct kexec_info *info,return -1 ; } - sz += align -1 ; - sz &= ~(align -1 ); + sz =_ALIGN (sz, align); bufp =xmalloc (sz);memset (bufp,0 , sz);kexec/fs2dt.c +2
-3@@ -697,8 +697,7 @@ static void add_boot_block(char **bufp, off_t *sizep)unsigned long tlen, toff;char *buf; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap =cpu_to_be32 (len);@@ -721,7 +720,7 @@ static void add_boot_block(char **bufp, off_t *sizep) len =propnum ("" ); bb->dt_strings_size =cpu_to_be32 (len); - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize =cpu_to_be32 (be32_to_cpu (bb->off_dt_strings) + len); bb->magic =cpu_to_be32 (0xd00dfeed );kexec/kexec-elf-boot.c +1
-1@@ -31,7 +31,7 @@#include "kexec-elf-boot.h" -#define UPSZ (X ) ((sizeof(X) + 3) &~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr;kexec/kexec-elf-rel.c +4
-4@@ -225,7 +225,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, buf_align = align; }/* Now align bufsz */ - bufsz = (bufsz + (align -1 )) & ~(align -1 ); + bufsz =_ALIGN (bufsz, align);/* And now add our buffer */ bufsz += shdr->sh_size; }@@ -237,7 +237,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, bss_align = align; }/* Now align bsssz */ - bsssz = (bsssz + (align -1 )) & ~(align -1 ); + bsssz =_ALIGN (bsssz, align);/* And now add our buffer */ bsssz += shdr->sh_size; }@@ -269,7 +269,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,if (shdr->sh_type !=SHT_NOBITS ) {unsigned long off;/* Adjust the address */ - data_addr = (data_addr + (align -1 )) & ~(align -1 ); + data_addr =_ALIGN (data_addr, align);/* Update the section */ off = data_addr - buf_addr;@@ -281,7 +281,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, data_addr += shdr->sh_size; }else {/* Adjust the address */ - bss_addr = (bss_addr + (align -1 )) & ~(align -1 ); + bss_addr =_ALIGN (bss_addr, align);/* Update the section */ shdr->sh_addr = bss_addr;kexec/kexec-elf.c +4
-4@@ -704,8 +704,8 @@ static int build_mem_notes(struct mem_ehdr *ehdr)ElfNN_Nhdr hdr;read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); - note_size += (hdr.n_namesz +3 ) & ~3 ; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); + note_size +=_ALIGN (hdr.n_descsz,4 ); ehdr->e_notenum +=1 ; }/* Now walk and normalize the notes */ @@ -716,9 +716,9 @@ static int build_mem_notes(struct mem_ehdr *ehdr)read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); name = note + note_size; - note_size += (hdr.n_namesz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); desc = note + note_size; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_descsz,4 );if ((hdr.n_namesz !=0 ) && (name[hdr.n_namesz -1 ] !='\0' )) {/* If note name string is not null terminated, just kexec/kexec.c +7
-8@@ -257,8 +257,7 @@ unsigned long locate_hole(struct kexec_info *info,if (start < hole_min) { start = hole_min; } - start = (start + hole_align -1 ) & - ~((unsigned long long )hole_align -1 ); + start =_ALIGN (start, hole_align);if (end > mem_max) { end = mem_max; }@@ -276,8 +275,8 @@ unsigned long locate_hole(struct kexec_info *info, hole_base = start;break ; }else { - hole_base = (end - hole_size) & - ~((unsigned long long )hole_align -1 ); + hole_base =_ALIGN_DOWN (end - hole_size, + hole_align); } } }@@ -313,7 +312,7 @@ void add_segment_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize);/* Verify base is pagesize aligned. * Finding a way to cope with this problem @@ -363,7 +362,7 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize); base =locate_hole (info, memsz, buf_align, buf_min, buf_max, buf_end);if (base ==ULONG_MAX ) {@@ -457,8 +456,8 @@ int add_backup_segments(struct kexec_info *info, unsigned long backup_base,return -1 ;if (!find_segment_hole (info, &bkseg_base, &bkseg_size))break ; - start = (bkseg_base + pagesize -1 ) & ~(pagesize -1 ); - end = (bkseg_base + bkseg_size) & ~(pagesize -1 ); + start =_ALIGN (bkseg_base, pagesize); + end =_ALIGN_DOWN (bkseg_base + bkseg_size, pagesize);add_segment_phys_virt (info,NULL ,0 , start, end-start,0 ); mem_size = mem_base + mem_size - \kexec/libfdt/libfdt_internal.h +1
-1@@ -52,7 +52,7 @@*/ #include <fdt.h> -#define FDT_ALIGN (x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define FDT_ALIGN (x, a) _ALIGN(x, a)#define FDT_TAGALIGN (x) (FDT_ALIGN((x), FDT_TAGSIZE))
Quoted 10 lines
Quoted 4 lines
kexec/libfdt/libfdt_internal.h +0
-0#define FDT_CHECK_HEADER (fdt) \Signature · 1 line
1.7.1_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 07/13] kexec: ia64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 6 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be simplified.
Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 08/13] kexec: mips: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 6 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v2 09/13] kexec: ppc: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 5 lines · Zhang Yanfei
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Besides, remove the duplicate _ALIGN_* definition in file
kexec/arch/ppc/crashdump-powerpc.h.
Hi,
I am still seeing a build problem with v2.
powerpc-linux-gnu-gcc -L/lib -o build/sbin/kexec kexec/kexec.o kexec/ifdown.o kexec/kexec-elf.o kexec/kexec-elf-exec.o kexec/kexec-elf-core.o kexec/kexec-elf-rel.o kexec/kexec-elf-boot.o kexec/kexec-iomem.o kexec/firmware_memmap.o kexec/crashdump.o kexec/crashdump-xen.o kexec/phys_arch.o kexec/kernel_version.o kexec/lzma.o kexec/zlib.o kexec/proc_iomem.o kexec/virt_to_phys.o kexec/phys_to_virt.o kexec/add_segment.o kexec/add_buffer.o kexec/kexec-uImage.o kexec/arch/ppc/kexec-ppc.o kexec/arch/ppc/kexec-elf-ppc.o kexec/arch/ppc/kexec-elf-rel-ppc.o kexec/arch/ppc/kexec-dol-ppc.o kexec/arch/ppc/kexec-uImage-ppc.o kexec/arch/ppc/ppc-setup-simple.o kexec/arch/ppc/ppc-setup-dol.o kexec/arch/ppc/fixup_dtb.o kexec/arch/ppc/fs2dt.o kexec/arch/ppc/crashdump-powerpc.o kexec/libfdt/fdt.o kexec/libfdt/fdt_ro.o kexec/libfdt/fdt_wip.o kexec/libfdt/fdt_sw.o kexec/libfdt/fdt_rw.o kexec/libfdt/fdt_strerror.o kexec/arch/ppc/libfdt-wrapper.o kexec/purgatory.o libutil.a -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypeskexec/libfdt/fdt.o: In function `fdt_next_tag':
fdt.c:(.text+0x304): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_begin_node':
fdt_sw.c:(.text+0x4f4): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_property':
fdt_sw.c:(.text+0x648): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_create':
fdt_sw.c:(.text+0x744): undefined reference to `_ALIGN'kexec/libfdt/fdt_rw.o: In function `_fdt_blocks_misordered':
fdt_rw.c:(.text+0x40): undefined reference to `_ALIGN'
kexec/libfdt/fdt_rw.o:fdt_rw.c:(.text+0x19c): more undefined references to
`_ALIGN' follow
collect2: ld returned 1 exit status
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v2 09/13] kexec: ppc: use _ALIGN* to make the logic clear
Quoted 11 lines · Simon Horman
Quoted 5 lines · Zhang Yanfei
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Besides, remove the duplicate _ALIGN_* definition in file
kexec/arch/ppc/crashdump-powerpc.h.Hi,
I am still seeing a build problem with v2.
Quoted 15 lines
powerpc-linux-gnu-gcc -L/lib -o build/sbin/kexec
kexec/kexec.okexec/ifdown.okexec/kexec-elf.okexec/kexec-elf-exec.okexec/kexec-elf-core.okexec/kexec-elf-rel.okexec/kexec-elf-boot.okexec/kexec-iomem.okexec/firmware_memmap.okexec/crashdump.okexec/crashdump-xen.okexec/phys_arch.okexec/kernel_version.okexec/lzma.okexec/zlib.okexec/proc_iomem.okexec/virt_to_phys.okexec/phys_to_virt.okexec/add_segment.okexec/add_buffer.okexec/kexec-uImage.okexec/arch/ppc/kexec-ppc.okexec/arch/ppc/kexec-elf-ppc.okexec/arch/ppc/kexec-elf-rel-ppc.okexec/arch/ppc/kexec-dol-ppc.okexec/arch/ppc/kexec-uImage-ppc.okexec/arch/ppc/ppc-setup-simple.okexec/arch/ppc/ppc-setup-dol.okexec/arch/ppc/fixup_dtb.okexec/arch/ppc/fs2dt.okexec/arch/ppc/crashdump-powerpc.okexec/libfdt/fdt.okexec/libfdt/fdt_ro.okexec/libfdt/fdt_wip.okexec/libfdt/fdt_sw.okexec/libfdt/fdt_rw.okexec/libfdt/fdt_strerror.okexec/arch/ppc/libfdt-wrapper.okexec/purgatory.olibutil.a -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypeskexec/libfdt/fdt.o: In function `fdt_next_tag':
fdt.c:(.text+0x304): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_begin_node':
fdt_sw.c:(.text+0x4f4): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_property':
fdt_sw.c:(.text+0x648): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_create':
fdt_sw.c:(.text+0x744): undefined reference to `_ALIGN'kexec/libfdt/fdt_rw.o: In function `_fdt_blocks_misordered':
fdt_rw.c:(.text+0x40): undefined reference to `_ALIGN'
kexec/libfdt/fdt_rw.o:fdt_rw.c:(.text+0x19c): more undefined references to
`_ALIGN' follow
collect2: ld returned 1 exit status
Actually, I think that the problem above relates to "kexec: use _ALIGN* to make the logic clear"
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 04/13] kexec: use _ALIGN* to make the logic clear
In reply to Simon HormanQuoted 4 lines · Simon Horman
Quoted 3 lines · Simon Horman
Quoted 2 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
Not a big deal, but I believe this patch needs to come after the arm changes in the series in order to avoid breaking the build on that architecture.
I have applied this as the last patch of this series that I have applied.
Actually, I take that back.
I am also seeing problems with this patch on ppc.
I have dropped this patch for now.
powerpc-linux-gnu-ar: creating libutil.a
powerpc-linux-gnu-gcc -L/lib -o build/sbin/kexec kexec/kexec.o kexec/ifdown.o kexec/kexec-elf.o kexec/kexec-elf-exec.o kexec/kexec-elf-core.o kexec/kexec-elf-rel.o kexec/kexec-elf-boot.o kexec/kexec-iomem.o kexec/firmware_memmap.o kexec/crashdump.o kexec/crashdump-xen.o kexec/phys_arch.o kexec/kernel_version.o kexec/lzma.o kexec/zlib.o kexec/proc_iomem.o kexec/virt_to_phys.o kexec/phys_to_virt.o kexec/add_segment.o kexec/add_buffer.o kexec/kexec-uImage.o kexec/arch/ppc/kexec-ppc.o kexec/arch/ppc/kexec-elf-ppc.o kexec/arch/ppc/kexec-elf-rel-ppc.o kexec/arch/ppc/kexec-dol-ppc.o kexec/arch/ppc/kexec-uImage-ppc.o kexec/arch/ppc/ppc-setup-simple.o kexec/arch/ppc/ppc-setup-dol.o kexec/arch/ppc/fixup_dtb.o kexec/arch/ppc/fs2dt.o kexec/arch/ppc/crashdump-powerpc.o kexec/libfdt/fdt.o kexec/libfdt/fdt_ro.o kexec/libfdt/fdt_wip.o kexec/libfdt/fdt_sw.o kexec/libfdt/fdt_rw.o kexec/libfdt/fdt_strerror.o kexec/arch/ppc/libfdt-wrapper.o kexec/purgatory.o libutil.a -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes kexec/libfdt/fdt.o: In function `fdt_next_tag':
fdt.c:(.text+0x304): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_begin_node':
fdt_sw.c:(.text+0x4f4): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_property':
fdt_sw.c:(.text+0x648): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_create':
fdt_sw.c:(.text+0x744): undefined reference to `_ALIGN'kexec/libfdt/fdt_rw.o: In function `_fdt_blocks_misordered':
fdt_rw.c:(.text+0x40): undefined reference to `_ALIGN'
kexec/libfdt/fdt_rw.o:fdt_rw.c:(.text+0x19c): more undefined references to `_ALIGN' follow
collect2: ld returned 1 exit status
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v2 09/13] kexec: ppc: use _ALIGN* to make the logic clear
In reply to Simon HormanQuoted 28 lines · Simon Horman
Quoted 11 lines · Simon Horman
Quoted 5 lines · Zhang Yanfei
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Besides, remove the duplicate _ALIGN_* definition in file
kexec/arch/ppc/crashdump-powerpc.h.Hi,
I am still seeing a build problem with v2.
Quoted 15 lines
powerpc-linux-gnu-gcc -L/lib -o build/sbin/kexec
kexec/kexec.okexec/ifdown.okexec/kexec-elf.okexec/kexec-elf-exec.okexec/kexec-elf-core.okexec/kexec-elf-rel.okexec/kexec-elf-boot.okexec/kexec-iomem.okexec/firmware_memmap.okexec/crashdump.okexec/crashdump-xen.okexec/phys_arch.okexec/kernel_version.okexec/lzma.okexec/zlib.okexec/proc_iomem.okexec/virt_to_phys.okexec/phys_to_virt.okexec/add_segment.okexec/add_buffer.okexec/kexec-uImage.okexec/arch/ppc/kexec-ppc.okexec/arch/ppc/kexec-elf-ppc.okexec/arch/ppc/kexec-elf-rel-ppc.okexec/arch/ppc/kexec-dol-ppc.okexec/arch/ppc/kexec-uImage-ppc.okexec/arch/ppc/ppc-setup-simple.okexec/arch/ppc/ppc-setup-dol.okexec/arch/ppc/fixup_dtb.okexec/arch/ppc/fs2dt.okexec/arch/ppc/crashdump-powerpc.okexec/libfdt/fdt.okexec/libfdt/fdt_ro.okexec/libfdt/fdt_wip.okexec/libfdt/fdt_sw.okexec/libfdt/fdt_rw.okexec/libfdt/fdt_strerror.okexec/arch/ppc/libfdt-wrapper.okexec/purgatory.olibutil.a -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypeskexec/libfdt/fdt.o: In function `fdt_next_tag':
fdt.c:(.text+0x304): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_begin_node':
fdt_sw.c:(.text+0x4f4): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_property':
fdt_sw.c:(.text+0x648): undefined reference to `_ALIGN'kexec/libfdt/fdt_sw.o: In function `fdt_create':
fdt_sw.c:(.text+0x744): undefined reference to `_ALIGN'kexec/libfdt/fdt_rw.o: In function `_fdt_blocks_misordered':
fdt_rw.c:(.text+0x40): undefined reference to `_ALIGN'
kexec/libfdt/fdt_rw.o:fdt_rw.c:(.text+0x19c): more undefined references to
`_ALIGN' follow
collect2: ld returned 1 exit status
Quoted 2 lines
Actually, I think that the problem above relates to "kexec: use _ALIGN* to make the logic clear"
Sorry for the confusion. I have applied this patch ("kexec: ppc: use _ALIGN* to make the logic clear") after dropping "kexec: use _ALIGN* to make the logic clear".
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 11/13] kexec: s390: remove ALIGN_UP and use _ALIGN_UP
In reply to Zhang YanfeiQuoted 6 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
We have
_ALIGN_UPnow, so removeALIGN_UPand use_ALIGN_UPinstead of it.Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 12/13] kexec: sh: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 6 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH 13/13] kexec: x86_64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 6 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH v2 10/13] kexec: ppc64: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 4 lines · Zhang Yanfei
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear.
Signed-off-by Zhang Yanfei <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 04/13] kexec: use _ALIGN* to make the logic clear
In reply to Zhang YanfeiQuoted 7 lines · Zhang Yanfei
Quoted 6 lines · Simon Horman
Quoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
Quoted 6 lines
Quoted 3 lines
Not a big deal, but I believe this patch needs to come after the arm changes in the series in order to avoid breaking the build on that architecture.
Sorry, could you explain more? I don't have an arm machine, so, I couldn't test them.
The problem is that kexec/fs2dt.c is used by ARM.
So _ALIGN() needs to be added to ARM before using _ALIGN() in kexec/fs2dt.c.
Quoted 4 lines
And I found a bug in this patch, still the ")" issue
kexec/fs2dt.c +1
-0+ len = _ALIGN(sizeof(bb[0], 8);
Quoted 210 lines
oops...
Quoted 206 lines
Quoted 200 lines
Signed-off-by Zhang Yanfei <[email protected]>--- kexec/crashdump-elf.c | 3 +-- kexec/fs2dt.c | 5 ++--- kexec/kexec-elf-boot.c | 2 +- kexec/kexec-elf-rel.c | 8 ++++---- kexec/kexec-elf.c | 8 ++++---- kexec/kexec.c | 15 +++++++-------- kexec/libfdt/libfdt_internal.h | 2 +- 7 files changed, 20 insertions(+), 23 deletions(-)kexec/crashdump-elf.c +1
-2@@ -96,8 +96,7 @@ int FUNC(struct kexec_info *info,return -1 ; } - sz += align -1 ; - sz &= ~(align -1 ); + sz =_ALIGN (sz, align); bufp =xmalloc (sz);memset (bufp,0 , sz);kexec/fs2dt.c +2
-3@@ -697,8 +697,7 @@ static void add_boot_block(char **bufp, off_t *sizep)unsigned long tlen, toff;char *buf; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len = _ALIGN(sizeof(bb[0], 8); bb->off_mem_rsvmap =cpu_to_be32 (len);@@ -721,7 +720,7 @@ static void add_boot_block(char **bufp, off_t *sizep) len =propnum ("" ); bb->dt_strings_size =cpu_to_be32 (len); - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize =cpu_to_be32 (be32_to_cpu (bb->off_dt_strings) + len); bb->magic =cpu_to_be32 (0xd00dfeed );kexec/kexec-elf-boot.c +1
-1@@ -31,7 +31,7 @@#include "kexec-elf-boot.h" -#define UPSZ (X ) ((sizeof(X) + 3) &~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr;kexec/kexec-elf-rel.c +4
-4@@ -225,7 +225,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, buf_align = align; }/* Now align bufsz */ - bufsz = (bufsz + (align -1 )) & ~(align -1 ); + bufsz =_ALIGN (bufsz, align);/* And now add our buffer */ bufsz += shdr->sh_size; }@@ -237,7 +237,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, bss_align = align; }/* Now align bsssz */ - bsssz = (bsssz + (align -1 )) & ~(align -1 ); + bsssz =_ALIGN (bsssz, align);/* And now add our buffer */ bsssz += shdr->sh_size; }@@ -269,7 +269,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,if (shdr->sh_type !=SHT_NOBITS ) {unsigned long off;/* Adjust the address */ - data_addr = (data_addr + (align -1 )) & ~(align -1 ); + data_addr =_ALIGN (data_addr, align);/* Update the section */ off = data_addr - buf_addr;@@ -281,7 +281,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, data_addr += shdr->sh_size; }else {/* Adjust the address */ - bss_addr = (bss_addr + (align -1 )) & ~(align -1 ); + bss_addr =_ALIGN (bss_addr, align);/* Update the section */ shdr->sh_addr = bss_addr;kexec/kexec-elf.c +4
-4@@ -704,8 +704,8 @@ static int build_mem_notes(struct mem_ehdr *ehdr)ElfNN_Nhdr hdr;read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); - note_size += (hdr.n_namesz +3 ) & ~3 ; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); + note_size +=_ALIGN (hdr.n_descsz,4 ); ehdr->e_notenum +=1 ; }/* Now walk and normalize the notes */ @@ -716,9 +716,9 @@ static int build_mem_notes(struct mem_ehdr *ehdr)read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); name = note + note_size; - note_size += (hdr.n_namesz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); desc = note + note_size; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_descsz,4 );if ((hdr.n_namesz !=0 ) && (name[hdr.n_namesz -1 ] !='\0' )) {/* If note name string is not null terminated, just kexec/kexec.c +7
-8@@ -257,8 +257,7 @@ unsigned long locate_hole(struct kexec_info *info,if (start < hole_min) { start = hole_min; } - start = (start + hole_align -1 ) & - ~((unsigned long long )hole_align -1 ); + start =_ALIGN (start, hole_align);if (end > mem_max) { end = mem_max; }@@ -276,8 +275,8 @@ unsigned long locate_hole(struct kexec_info *info, hole_base = start;break ; }else { - hole_base = (end - hole_size) & - ~((unsigned long long )hole_align -1 ); + hole_base =_ALIGN_DOWN (end - hole_size, + hole_align); } } }@@ -313,7 +312,7 @@ void add_segment_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize);/* Verify base is pagesize aligned. * Finding a way to cope with this problem @@ -363,7 +362,7 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize); base =locate_hole (info, memsz, buf_align, buf_min, buf_max, buf_end);if (base ==ULONG_MAX ) {@@ -457,8 +456,8 @@ int add_backup_segments(struct kexec_info *info, unsigned long backup_base,return -1 ;if (!find_segment_hole (info, &bkseg_base, &bkseg_size))break ; - start = (bkseg_base + pagesize -1 ) & ~(pagesize -1 ); - end = (bkseg_base + bkseg_size) & ~(pagesize -1 ); + start =_ALIGN (bkseg_base, pagesize); + end =_ALIGN_DOWN (bkseg_base + bkseg_size, pagesize);add_segment_phys_virt (info,NULL ,0 , start, end-start,0 ); mem_size = mem_base + mem_size - \kexec/libfdt/libfdt_internal.h +1
-1@@ -52,7 +52,7 @@*/ #include <fdt.h> -#define FDT_ALIGN (x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define FDT_ALIGN (x, a) _ALIGN(x, a)#define FDT_TAGALIGN (x) (FDT_ALIGN((x), FDT_TAGSIZE))#define FDT_CHECK_HEADER (fdt) \Signature · 1 line
1.7.1_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v2 4/13 kexec: use _ALIGN* to make the logic clear
In reply to Simon HormanFrom: Zhang Yanfei <[email protected]>
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could more clear.
--- kexec/crashdump-elf.c | 3 +-- kexec/fs2dt.c | 5 ++--- kexec/kexec-elf-boot.c | 2 +- kexec/kexec-elf-rel.c | 8 ++++---- kexec/kexec-elf.c | 8 ++++---- kexec/kexec.c | 15 +++++++-------- kexec/libfdt/libfdt_internal.h | 2 +- 7 files changed, 20 insertions(+), 23 deletions(-)
kexec/crashdump-elf.c +1 -2
@@ -96,8 +96,7 @@ int FUNC(struct kexec_info *info,return -1 ; } - sz += align -1 ; - sz &= ~(align -1 ); + sz =_ALIGN (sz, align); bufp =xmalloc (sz);memset (bufp,0 , sz);
kexec/fs2dt.c +2 -3
@@ -697,8 +697,7 @@ static void add_boot_block(char **bufp, off_t *sizep)unsigned long tlen, toff;char *buf; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len =_ALIGN (sizeof (bb[0 ]),8 ); bb->off_mem_rsvmap =cpu_to_be32 (len);
@@ -721,7 +720,7 @@ static void add_boot_block(char **bufp, off_t *sizep) len =propnum ("" ); bb->dt_strings_size =cpu_to_be32 (len); - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize =cpu_to_be32 (be32_to_cpu (bb->off_dt_strings) + len); bb->magic =cpu_to_be32 (0xd00dfeed );
kexec/kexec-elf-boot.c +1 -1
@@ -31,7 +31,7 @@#include "kexec-elf-boot.h" -#define UPSZ (X ) ((sizeof(X) + 3) &~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr;
kexec/kexec-elf-rel.c +4 -4
@@ -225,7 +225,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, buf_align = align; }/* Now align bufsz */ - bufsz = (bufsz + (align -1 )) & ~(align -1 ); + bufsz =_ALIGN (bufsz, align);/* And now add our buffer */ bufsz += shdr->sh_size; }
@@ -237,7 +237,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, bss_align = align; }/* Now align bsssz */ - bsssz = (bsssz + (align -1 )) & ~(align -1 ); + bsssz =_ALIGN (bsssz, align);/* And now add our buffer */ bsssz += shdr->sh_size; }
@@ -269,7 +269,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,if (shdr->sh_type !=SHT_NOBITS ) {unsigned long off;/* Adjust the address */ - data_addr = (data_addr + (align -1 )) & ~(align -1 ); + data_addr =_ALIGN (data_addr, align);/* Update the section */ off = data_addr - buf_addr;
@@ -281,7 +281,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, data_addr += shdr->sh_size; }else {/* Adjust the address */ - bss_addr = (bss_addr + (align -1 )) & ~(align -1 ); + bss_addr =_ALIGN (bss_addr, align);/* Update the section */ shdr->sh_addr = bss_addr;
kexec/kexec-elf.c +4 -4
@@ -704,8 +704,8 @@ static int build_mem_notes(struct mem_ehdr *ehdr)ElfNN_Nhdr hdr;read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); - note_size += (hdr.n_namesz +3 ) & ~3 ; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); + note_size +=_ALIGN (hdr.n_descsz,4 ); ehdr->e_notenum +=1 ; }/* Now walk and normalize the notes */
@@ -716,9 +716,9 @@ static int build_mem_notes(struct mem_ehdr *ehdr)read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); name = note + note_size; - note_size += (hdr.n_namesz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); desc = note + note_size; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_descsz,4 );if ((hdr.n_namesz !=0 ) && (name[hdr.n_namesz -1 ] !='\0' )) {/* If note name string is not null terminated, just
kexec/kexec.c +7 -8
@@ -257,8 +257,7 @@ unsigned long locate_hole(struct kexec_info *info,if (start < hole_min) { start = hole_min; } - start = (start + hole_align -1 ) & - ~((unsigned long long )hole_align -1 ); + start =_ALIGN (start, hole_align);if (end > mem_max) { end = mem_max; }
@@ -276,8 +275,8 @@ unsigned long locate_hole(struct kexec_info *info, hole_base = start;break ; }else { - hole_base = (end - hole_size) & - ~((unsigned long long )hole_align -1 ); + hole_base =_ALIGN_DOWN (end - hole_size, + hole_align); } } }
@@ -313,7 +312,7 @@ void add_segment_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize);/* Verify base is pagesize aligned. * Finding a way to cope with this problem
@@ -363,7 +362,7 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize); base =locate_hole (info, memsz, buf_align, buf_min, buf_max, buf_end);if (base ==ULONG_MAX ) {
@@ -457,8 +456,8 @@ int add_backup_segments(struct kexec_info *info, unsigned long backup_base,return -1 ;if (!find_segment_hole (info, &bkseg_base, &bkseg_size))break ; - start = (bkseg_base + pagesize -1 ) & ~(pagesize -1 ); - end = (bkseg_base + bkseg_size) & ~(pagesize -1 ); + start =_ALIGN (bkseg_base, pagesize); + end =_ALIGN_DOWN (bkseg_base + bkseg_size, pagesize);add_segment_phys_virt (info,NULL ,0 , start, end-start,0 ); mem_size = mem_base + mem_size - \
kexec/libfdt/libfdt_internal.h +1 -1
@@ -52,7 +52,7 @@*/ #include <fdt.h> -#define FDT_ALIGN (x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define FDT_ALIGN (x, a) _ALIGN(x, a)#define FDT_TAGALIGN (x) (FDT_ALIGN((x), FDT_TAGSIZE))#define FDT_CHECK_HEADER (fdt) \
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 04/13] kexec: use _ALIGN* to make the logic clear
In reply to Simon HormanQuoted 14 lines · Simon Horman
Quoted 4 lines · Simon Horman
Quoted 3 lines · Simon Horman
Quoted 2 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
Not a big deal, but I believe this patch needs to come after the arm changes in the series in order to avoid breaking the build on that architecture.
I have applied this as the last patch of this series that I have applied.
Quoted 7 lines
Actually, I take that back.
I am also seeing problems with this patch on ppc.
I have dropped this patch for now.powerpc-linux-gnu-ar: creating libutil.a
powerpc-linux-gnu-gcc -L/lib -o build/sbin/kexeckexec/kexec.okexec/ifdown.okexec/kexec-elf.okexec/kexec-elf-exec.okexec/kexec-elf-core.okexec/kexec-elf-rel.okexec/kexec-elf-boot.okexec/kexec-iomem.okexec/firmware_memmap.okexec/crashdump.okexec/crashdump-xen.okexec/phys_arch.okexec/kernel_version.okexec/lzma.okexec/zlib.okexec/proc_iomem.okexec/virt_to_phys.okexec/phys_to_virt.okexec/add_segment.okexec/add_buffer.okexec/kexec-uImage.okexec/arch/ppc/kexec-ppc.okexec/arch/ppc/kexec-elf-ppc.okexec/arch/ppc/kexec-elf-rel-ppc.okexec/arch/ppc/kexec-dol-ppc.okexec/arch/ppc/kexec-uImage-ppc.okexec/arch/ppc/ppc-setup-simple.okexec/arch/ppc/ppc-setup-dol.okexec/arch/ppc/fixup_dtb.okexec/arch/ppc/fs2dt.okexec/arch/ppc/crashdump-powerpc.okexec/libfdt/fdt.okexec/libfdt/fdt_ro.okexec/libfdt/fdt_wip.okexec/libfdt/fdt_sw.okexec/libfdt/fdt_rw.okexec/libfdt/fdt_strerror.okexec/arch/ppc/libfdt-wrapper.okexec/purgatory.olibutil.a -Wall -Wextra -Wpointer-arith -Ww
rite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes
Quoted 4 lines
kexec/libfdt/fdt.o: In function `fdt_next_tag':
fdt.c:(.text+0x304): undefined reference to_ALIGN' kexec/libfdt/fdt_sw.o: In functionfdt_begin_node':
fdt_sw.c:(.text+0x4f4): undefined reference to `_ALIGN'
Quoted 8 lines
kexec/libfdt/fdt_sw.o: In function `fdt_property':
fdt_sw.c:(.text+0x648): undefined reference to_ALIGN' kexec/libfdt/fdt_sw.o: In functionfdt_create':
fdt_sw.c:(.text+0x744): undefined reference to_ALIGN' kexec/libfdt/fdt_rw.o: In function_fdt_blocks_misordered':
fdt_rw.c:(.text+0x40): undefined reference to_ALIGN' kexec/libfdt/fdt_rw.o:fdt_rw.c:(.text+0x19c): more undefined references to_ALIGN' follow
collect2: ld returned 1 exit status
Hi simon,
Could you try the v2, please?
Thanks
Zhang
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 04/13] kexec: use _ALIGN* to make the logic clear
Quoted 36 lines · Zhang Yanfei
Quoted 14 lines · Simon Horman
Quoted 4 lines · Simon Horman
Quoted 3 lines · Simon Horman
Quoted 2 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
By replacing all the explicit align opertions with marco _ALIGN*, the code logic could be more clear.
Not a big deal, but I believe this patch needs to come after the arm changes in the series in order to avoid breaking the build on that architecture.
I have applied this as the last patch of this series that I have applied.
Quoted 7 lines
Actually, I take that back.
I am also seeing problems with this patch on ppc.
I have dropped this patch for now.powerpc-linux-gnu-ar: creating libutil.a
powerpc-linux-gnu-gcc -L/lib -o build/sbin/kexeckexec/kexec.okexec/ifdown.okexec/kexec-elf.okexec/kexec-elf-exec.okexec/kexec-elf-core.okexec/kexec-elf-rel.okexec/kexec-elf-boot.okexec/kexec-iomem.okexec/firmware_memmap.okexec/crashdump.okexec/crashdump-xen.okexec/phys_arch.okexec/kernel_version.okexec/lzma.okexec/zlib.okexec/proc_iomem.okexec/virt_to_phys.okexec/phys_to_virt.okexec/add_segment.okexec/add_buffer.okexec/kexec-uImage.okexec/arch/ppc/kexec-ppc.okexec/arch/ppc/kexec-elf-ppc.okexec/arch/ppc/kexec-elf-rel-ppc.okexec/arch/ppc/kexec-dol-ppc.okexec/arch/ppc/kexec-uImage-ppc.okexec/arch/ppc/ppc-setup-simple.okexec/arch/ppc/ppc-setup-dol.okexec/arch/ppc/fixup_dtb.okexec/arch/ppc/fs2dt.okexec/arch/ppc/crashdump-powerpc.okexec/libfdt/fdt.okexec/libfdt/fdt_ro.okexec/libfdt/fdt_wip.okexec/libfdt/fdt_sw.okexec/libfdt/fdt_rw.okexec/libfdt/fdt_strerror.okexec/arch/ppc/libfdt-wrapper.okexec/purgatory.olibutil.a -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat -O2 -fomit-frame-pointer -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes
Quoted 4 lines
kexec/libfdt/fdt.o: In function `fdt_next_tag':
fdt.c:(.text+0x304): undefined reference to_ALIGN' kexec/libfdt/fdt_sw.o: In functionfdt_begin_node':
fdt_sw.c:(.text+0x4f4): undefined reference to `_ALIGN'Quoted 8 lines
kexec/libfdt/fdt_sw.o: In function `fdt_property':
fdt_sw.c:(.text+0x648): undefined reference to_ALIGN' kexec/libfdt/fdt_sw.o: In functionfdt_create':
fdt_sw.c:(.text+0x744): undefined reference to_ALIGN' kexec/libfdt/fdt_rw.o: In function_fdt_blocks_misordered':
fdt_rw.c:(.text+0x40): undefined reference to_ALIGN' kexec/libfdt/fdt_rw.o:fdt_rw.c:(.text+0x19c): more undefined references to_ALIGN' follow
collect2: ld returned 1 exit status
Quoted 3 lines
Hi simon,
Could you try the v2, please?
Unfortunately I am still seeing the same problem with v2.
What I suggest is that we drop the kexec/libfdt/libfdt_internal.h portion of the patch entirely. With that version in place I can compile the code cleanly for all supported architectures.
If you are ok with this change could you please send it as v3?
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 4/13 kexec: use _ALIGN* to make the logic clear
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could more clear.
--- kexec/crashdump-elf.c | 3 +-- kexec/fs2dt.c | 5 ++--- kexec/kexec-elf-boot.c | 2 +- kexec/kexec-elf-rel.c | 8 ++++---- kexec/kexec-elf.c | 8 ++++---- kexec/kexec.c | 15 +++++++-------- 6 files changed, 19 insertions(+), 22 deletions(-)
kexec/crashdump-elf.c +1 -2
@@ -96,8 +96,7 @@ int FUNC(struct kexec_info *info,return -1 ; } - sz += align -1 ; - sz &= ~(align -1 ); + sz =_ALIGN (sz, align); bufp =xmalloc (sz);memset (bufp,0 , sz);
kexec/fs2dt.c +2 -3
@@ -697,8 +697,7 @@ static void add_boot_block(char **bufp, off_t *sizep)unsigned long tlen, toff;char *buf; - len =sizeof (bb[0 ]); - len +=7 ; len &= ~7 ; + len =_ALIGN (sizeof (bb[0 ]),8 ); bb->off_mem_rsvmap =cpu_to_be32 (len);
@@ -721,7 +720,7 @@ static void add_boot_block(char **bufp, off_t *sizep) len =propnum ("" ); bb->dt_strings_size =cpu_to_be32 (len); - len +=3 ; len &= ~3 ; + len =_ALIGN (len,4 ); bb->totalsize =cpu_to_be32 (be32_to_cpu (bb->off_dt_strings) + len); bb->magic =cpu_to_be32 (0xd00dfeed );
kexec/kexec-elf-boot.c +1 -1
@@ -31,7 +31,7 @@#include "kexec-elf-boot.h" -#define UPSZ (X ) ((sizeof(X) + 3) &~3) +#define UPSZ (X ) _ALIGN_UP(sizeof(X), 4) static struct boot_notes { Elf_Bhdr hdr;
kexec/kexec-elf-rel.c +4 -4
@@ -225,7 +225,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, buf_align = align; }/* Now align bufsz */ - bufsz = (bufsz + (align -1 )) & ~(align -1 ); + bufsz =_ALIGN (bufsz, align);/* And now add our buffer */ bufsz += shdr->sh_size; }
@@ -237,7 +237,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, bss_align = align; }/* Now align bsssz */ - bsssz = (bsssz + (align -1 )) & ~(align -1 ); + bsssz =_ALIGN (bsssz, align);/* And now add our buffer */ bsssz += shdr->sh_size; }
@@ -269,7 +269,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,if (shdr->sh_type !=SHT_NOBITS ) {unsigned long off;/* Adjust the address */ - data_addr = (data_addr + (align -1 )) & ~(align -1 ); + data_addr =_ALIGN (data_addr, align);/* Update the section */ off = data_addr - buf_addr;
@@ -281,7 +281,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, data_addr += shdr->sh_size; }else {/* Adjust the address */ - bss_addr = (bss_addr + (align -1 )) & ~(align -1 ); + bss_addr =_ALIGN (bss_addr, align);/* Update the section */ shdr->sh_addr = bss_addr;
kexec/kexec-elf.c +4 -4
@@ -704,8 +704,8 @@ static int build_mem_notes(struct mem_ehdr *ehdr)ElfNN_Nhdr hdr;read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); - note_size += (hdr.n_namesz +3 ) & ~3 ; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); + note_size +=_ALIGN (hdr.n_descsz,4 ); ehdr->e_notenum +=1 ; }/* Now walk and normalize the notes */
@@ -716,9 +716,9 @@ static int build_mem_notes(struct mem_ehdr *ehdr)read_nhdr (ehdr, &hdr, note); note_size =sizeof (hdr); name = note + note_size; - note_size += (hdr.n_namesz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_namesz,4 ); desc = note + note_size; - note_size += (hdr.n_descsz +3 ) & ~3 ; + note_size +=_ALIGN (hdr.n_descsz,4 );if ((hdr.n_namesz !=0 ) && (name[hdr.n_namesz -1 ] !='\0' )) {/* If note name string is not null terminated, just
kexec/kexec.c +7 -8
@@ -257,8 +257,7 @@ unsigned long locate_hole(struct kexec_info *info,if (start < hole_min) { start = hole_min; } - start = (start + hole_align -1 ) & - ~((unsigned long long )hole_align -1 ); + start =_ALIGN (start, hole_align);if (end > mem_max) { end = mem_max; }
@@ -276,8 +275,8 @@ unsigned long locate_hole(struct kexec_info *info, hole_base = start;break ; }else { - hole_base = (end - hole_size) & - ~((unsigned long long )hole_align -1 ); + hole_base =_ALIGN_DOWN (end - hole_size, + hole_align); } } }
@@ -313,7 +312,7 @@ void add_segment_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize);/* Verify base is pagesize aligned. * Finding a way to cope with this problem
@@ -363,7 +362,7 @@ unsigned long add_buffer_phys_virt(struct kexec_info *info,/* Round memsz up to a multiple of pagesize */ pagesize =getpagesize (); - memsz = (memsz + (pagesize -1 )) & ~(pagesize -1 ); + memsz =_ALIGN (memsz, pagesize); base =locate_hole (info, memsz, buf_align, buf_min, buf_max, buf_end);if (base ==ULONG_MAX ) {
@@ -457,8 +456,8 @@ int add_backup_segments(struct kexec_info *info, unsigned long backup_base,return -1 ;if (!find_segment_hole (info, &bkseg_base, &bkseg_size))break ; - start = (bkseg_base + pagesize -1 ) & ~(pagesize -1 ); - end = (bkseg_base + bkseg_size) & ~(pagesize -1 ); + start =_ALIGN (bkseg_base, pagesize); + end =_ALIGN_DOWN (bkseg_base + bkseg_size, pagesize);add_segment_phys_virt (info,NULL ,0 , start, end-start,0 ); mem_size = mem_base + mem_size - \
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedRe: [PATCH v3 04/13] kexec: use _ALIGN* to make the logic clear
Quoted 2 lines · Zhang Yanfei
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could more clear.
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec