Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/68267 )
Change subject: treewide: Replace ALIGN(x, a) by ALIGN_UP(x, a) for clarity ......................................................................
treewide: Replace ALIGN(x, a) by ALIGN_UP(x, a) for clarity
Change-Id: I2a255cdcbcd38406f008a26fc0ed68d532e7a721 Signed-off-by: Elyes Haouas ehaouas@noos.fr Reviewed-on: https://review.coreboot.org/c/coreboot/+/68267 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Felix Held felix-coreboot@felixheld.de --- M src/soc/amd/morgana/agesa_acpi.c M src/vendorcode/google/chromeos/vpd_calibration.c M util/cbfstool/cbfs-payload-linux.c M util/cbfstool/elfheaders.c M util/cbfstool/ifwitool.c 5 files changed, 27 insertions(+), 12 deletions(-)
Approvals: build bot (Jenkins): Verified Felix Held: Looks good to me, approved
diff --git a/src/soc/amd/morgana/agesa_acpi.c b/src/soc/amd/morgana/agesa_acpi.c index 78c0e4c..8838d9d 100644 --- a/src/soc/amd/morgana/agesa_acpi.c +++ b/src/soc/amd/morgana/agesa_acpi.c @@ -4,6 +4,7 @@
#include <acpi/acpi.h> #include <amdblocks/acpi.h> +#include <commonlib/bsd/helpers.h> #include <device/device.h> #include <FspGuids.h> #include <soc/acpi.h> @@ -18,7 +19,7 @@ current = add_agesa_fsp_acpi_table(AMD_FSP_ACPI_ALIB_HOB_GUID, "ALIB", rsdp, current);
/* IVRS */ - current = ALIGN(current, 8); + current = ALIGN_UP(current, 8); ivrs = (acpi_ivrs_t *)current; acpi_create_ivrs(ivrs, acpi_fill_ivrs); current += ivrs->header.length; diff --git a/src/vendorcode/google/chromeos/vpd_calibration.c b/src/vendorcode/google/chromeos/vpd_calibration.c index 460d7dc..e5f5b57 100644 --- a/src/vendorcode/google/chromeos/vpd_calibration.c +++ b/src/vendorcode/google/chromeos/vpd_calibration.c @@ -126,7 +126,7 @@ cache->key_size = key_length; cache->value_size = decoded_size; cache->blob_size = - ALIGN(sizeof(struct calibration_blob) + + ALIGN_UP(sizeof(struct calibration_blob) + cache->key_size + cache->value_size, 4); cbmem_entry_size += cache->blob_size; diff --git a/util/cbfstool/cbfs-payload-linux.c b/util/cbfstool/cbfs-payload-linux.c index 9a29e68..f9d0d11 100644 --- a/util/cbfstool/cbfs-payload-linux.c +++ b/util/cbfstool/cbfs-payload-linux.c @@ -253,7 +253,7 @@ /* 16 MB should be way outside coreboot's playground, * so if possible (relocatable kernel) use that to * avoid a trampoline copy. */ - kernel_base = ALIGN(16*1024*1024, params.kernel_alignment); + kernel_base = ALIGN_UP(16*1024*1024, params.kernel_alignment); if (hdr->init_size == 0) { ERROR("init_size 0 for relocatable kernel\n"); return -1; @@ -275,7 +275,7 @@ * close to the kernel, so give it some room. */ initrd_base = kernel_base + buffer_size(&bzp.kernel); - initrd_base = ALIGN(initrd_base, 64*1024*1024); + initrd_base = ALIGN_UP(initrd_base, 64*1024*1024);
params.initrd_start = initrd_base; params.initrd_size = buffer_size(&bzp.initrd); diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c index 3a53735..39faff2 100644 --- a/util/cbfstool/elfheaders.c +++ b/util/cbfstool/elfheaders.c @@ -1174,7 +1174,7 @@ metadata_size += (Elf64_Xword)ew->ehdr.e_phnum * ew->ehdr.e_phentsize; shstroffset = metadata_size; /* Align up section header string size and metadata size to 4KiB */ - metadata_size = ALIGN(metadata_size + shstrlen, 4096); + metadata_size = ALIGN_UP(metadata_size + shstrlen, 4096);
if (buffer_create(out, metadata_size + program_size, "elfout")) { ERROR("Could not create output buffer for ELF.\n"); diff --git a/util/cbfstool/ifwitool.c b/util/cbfstool/ifwitool.c index 8eda4c7..efcb594 100644 --- a/util/cbfstool/ifwitool.c +++ b/util/cbfstool/ifwitool.c @@ -1,6 +1,7 @@ /* ifwitool, CLI utility for IFWI manipulation */ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <commonlib/bsd/helpers.h> #include <commonlib/endian.h> #include <getopt.h> #include <stdlib.h> @@ -909,7 +910,7 @@ * part of the image. * ASSUMPTION: IFWI image always ends on a 4K boundary. */ - ifwi_image.input_ifwi_end_offset = ALIGN(end_offset, 4 * KiB); + ifwi_image.input_ifwi_end_offset = ALIGN_UP(end_offset, 4 * KiB); DEBUG("Parsing done.\n");
return 0; @@ -979,7 +980,7 @@ __bpdt_reset(&ifwi_image.bpdt, bpdt_count, bpdt_size);
/* Update S-BPDT if required. */ - bpdt_size = ALIGN(BPDT_HEADER_SIZE + sbpdt_count * BPDT_ENTRY_SIZE, + bpdt_size = ALIGN_UP(BPDT_HEADER_SIZE + sbpdt_count * BPDT_ENTRY_SIZE, 4 * KiB); __bpdt_reset(&ifwi_image.subpart_buf[S_BPDT_TYPE], sbpdt_count, bpdt_size); @@ -1091,7 +1092,7 @@ }
/* Pad ff bytes if there is any empty space left in BPDT 4K. */ - curr_end = ALIGN(curr_offset, 4 * KiB); + curr_end = ALIGN_UP(curr_offset, 4 * KiB); pad_buffer(last_bpdt_buff, buffer_size(last_bpdt_buff) + (curr_end - curr_offset)); curr_offset = curr_end; @@ -1107,9 +1108,9 @@ if (subparts[type].attr & LIES_WITHIN_BPDT_4K) continue;
- assert(curr_offset == ALIGN(curr_offset, 4 * KiB)); + assert(curr_offset == ALIGN_UP(curr_offset, 4 * KiB)); curr->offset = curr_offset; - curr_end = ALIGN(curr->offset + curr->size, 4 * KiB); + curr_end = ALIGN_UP(curr->offset + curr->size, 4 * KiB); curr->size = curr_end - curr->offset;
pad_buffer(&ifwi_image.subpart_buf[type], curr->size); @@ -1130,7 +1131,7 @@ curr = find_entry_by_type(S_BPDT_TYPE); assert(curr);
- assert(curr_offset == ALIGN(curr_offset, 4 * KiB)); + assert(curr_offset == ALIGN_UP(curr_offset, 4 * KiB)); curr->size = curr_offset - curr->offset; }
@@ -1190,7 +1191,7 @@ size_t ifwi_start, ifwi_end, file_end;
ifwi_start = ifwi_image.input_ifwi_start_offset; - ifwi_end = ifwi_start + ALIGN(s->offset + s->size, 4 * KiB); + ifwi_end = ifwi_start + ALIGN_UP(s->offset + s->size, 4 * KiB); file_end = ifwi_end + (buffer_size(&ifwi_image.input_buff) - ifwi_image.input_ifwi_end_offset);