summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-05-19 17:32:40 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2023-05-23 00:52:44 +0000
commitf15e6a105b1cf589476042e62b8d0bb64a938e38 (patch)
tree809937c5028f8d4f990eac81169f8f246fe7e7cc /flashrom.c
parent2e81c05ad34a08e341b2ddc69648efe5751a54b1 (diff)
downloadflashrom-f15e6a105b1cf589476042e62b8d0bb64a938e38.tar.gz
flashrom-f15e6a105b1cf589476042e62b8d0bb64a938e38.tar.bz2
flashrom-f15e6a105b1cf589476042e62b8d0bb64a938e38.zip
programmer: Use correct type for flashbase
The flashbase is a machine-sized integer representation of address space and so use the appropriate type that is correctly sized to encode such data. The flashbase is assigned to 'base' in 'map_flash()' and the type correctly changed to uintptr_t in commit 4e32ec19b124a7 therefore makes for a consistent type usage whenever stored. While `sizeof(unsigned long)` and `sizeof(uintptr_t)` are both `8` under most circumstances on a 64bit platform and thus have enough bits to represent all addresses on the platform, the C standard does not guarantee this. Only `uintptr_t` and `void *` has a guaranteed isomorphism as `uintptr_t` is defined by the platforms toolchain support whereas the conversion from `void *` to an integer is implementation defined and that the memory address value may contain additional bits describing the validation data or provenance of the address. Therefore a integer is insufficient to contain all the necessary information for that specific platform so this may not always work out for all platforms and toolchain combinations. Spotted-by: Martin Roth <martin.roth@amd.corp-partner.google.com> Change-Id: Ib9057e438731b9cccde0e24d5c8f758c3af1d47f Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/75328 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/flashrom.c b/flashrom.c
index 19afb5446..b6e5cf85a 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <stdio.h>
+#include <stdint.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
@@ -48,7 +49,7 @@ static const struct programmer_entry *programmer = NULL;
struct decode_sizes max_rom_decode;
/* If nonzero, used as the start address of bottom-aligned flash. */
-unsigned long flashbase;
+uintptr_t flashbase;
/* Is writing allowed with this programmer? */
bool programmer_may_write;