summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang Yanfei <zhangyanfei@cn.fujitsu.com>2013-03-14 01:28:36 +0800
committerSimon Horman <horms@verge.net.au>2013-03-14 09:45:16 +0100
commit8388bdce82c79452b93b3a1fa5c77d15dcbd0a18 (patch)
tree6dc940c928f43086e8be965168eab2b149a73cfa
parent0c1b89d3ca04ef7211c11243df590dba83fc2dc8 (diff)
downloadkexec-tools-8388bdce82c79452b93b3a1fa5c77d15dcbd0a18.tar.gz
kexec: i386: use _ALIGN* to make the logic clear
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could be more clear. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/arch/i386/crashdump-x86.c6
-rw-r--r--kexec/arch/i386/kexec-bzImage.c2
-rw-r--r--kexec/arch/i386/kexec-multiboot-x86.c5
3 files changed, 6 insertions, 7 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 5cbe1534..5462f8b0 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -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,
diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index bad0c9c9..99fd790f 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -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;
diff --git a/kexec/arch/i386/kexec-multiboot-x86.c b/kexec/arch/i386/kexec-multiboot-x86.c
index de2a423c..3f787e13 100644
--- a/kexec/arch/i386/kexec-multiboot-x86.c
+++ b/kexec/arch/i386/kexec-multiboot-x86.c
@@ -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));