Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/62817 )
Change subject: [WIP]src/*: Fix void pointer aritmetics ......................................................................
[WIP]src/*: Fix void pointer aritmetics
Fix undefined C code and add a CFLAG a warning about it.
Change-Id: Ic6dfb30c426867c3176a9426c2909702b40cc577 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M Makefile.inc M src/acpi/acpi.c M src/acpi/device.c M src/arch/x86/ioapic.c M src/commonlib/bsd/cbfs_mcache.c M src/commonlib/bsd/cbfs_private.c M src/commonlib/bsd/elog.c M src/commonlib/bsd/lz4_wrapper.c M src/cpu/x86/lapic/lapic_cpu_init.c M src/cpu/x86/pae/pgtbl.c M src/device/mmio.c M src/device/pci_rom.c M src/drivers/mipi/panel.c M src/drivers/spi/bitbang.c M src/lib/cbfs.c M src/lib/hexdump.c M src/lib/lzma.c M src/lib/malloc.c M src/lib/rmodule.c M src/lib/stack.c 20 files changed, 80 insertions(+), 58 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/17/62817/1
diff --git a/Makefile.inc b/Makefile.inc index ec2d097..77ec1d0 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -435,6 +435,7 @@ CFLAGS_common += -Wdangling-else CFLAGS_common += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer CFLAGS_common += -fstrict-aliasing -ffunction-sections -fdata-sections -fno-pie +CFLAGS_common += -Wpointer-arith ifeq ($(CONFIG_COMPILER_GCC),y) # Don't add these GCC specific flags when running scan-build ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),) diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c index 78d5f07..60fd0e3 100644 --- a/src/acpi/acpi.c +++ b/src/acpi/acpi.c @@ -26,6 +26,7 @@ #include <device/mmio.h> #include <device/pci.h> #include <pc80/mc146818rtc.h> +#include <stdint.h> #include <string.h> #include <types.h> #include <version.h> @@ -1621,9 +1622,9 @@ if (fw) { rsdp = NULL; /* Find RSDP. */ - for (void *p = (void *)current; p < (void *)fw; p += 16) { + for (uintptr_t p = current; p < (uintptr_t)fw; p += 16) { if (valid_rsdp((acpi_rsdp_t *)p)) { - rsdp = p; + rsdp = (void *)p; break; } } diff --git a/src/acpi/device.c b/src/acpi/device.c index 1df179b..d4bd2c3 100644 --- a/src/acpi/device.c +++ b/src/acpi/device.c @@ -42,7 +42,7 @@ */ static void acpi_device_fill_len(void *ptr) { - acpi_device_fill_from_len(ptr, ptr + sizeof(uint16_t)); + acpi_device_fill_from_len(ptr, (char *)ptr + sizeof(uint16_t)); }
/* Locate and return the ACPI name for this device */ diff --git a/src/arch/x86/ioapic.c b/src/arch/x86/ioapic.c index d65637c..518a516 100644 --- a/src/arch/x86/ioapic.c +++ b/src/arch/x86/ioapic.c @@ -5,17 +5,18 @@ #include <arch/ioapic.h> #include <console/console.h> #include <cpu/x86/lapic.h> +#include <stdint.h>
u32 io_apic_read(void *ioapic_base, u32 reg) { write32(ioapic_base, reg); - return read32(ioapic_base + 0x10); + return read32p((uintptr_t)ioapic_base + 0x10); }
void io_apic_write(void *ioapic_base, u32 reg, u32 value) { write32(ioapic_base, reg); - write32(ioapic_base + 0x10, value); + write32p((uintptr_t)ioapic_base + 0x10, value); }
static void write_vector(void *ioapic_base, u8 vector, u32 high, u32 low) diff --git a/src/commonlib/bsd/cbfs_mcache.c b/src/commonlib/bsd/cbfs_mcache.c index 29ba110..ab1ab40 100644 --- a/src/commonlib/bsd/cbfs_mcache.c +++ b/src/commonlib/bsd/cbfs_mcache.c @@ -2,6 +2,7 @@
#include <assert.h> #include <commonlib/bsd/cbfs_private.h> +#include <stdint.h>
/* * A CBFS metadata cache is an in memory data structure storing CBFS file headers (= metadata). @@ -35,8 +36,8 @@ };
struct cbfs_mcache_build_args { - void *mcache; - void *end; + uintptr_t mcache; + uintptr_t end; int count; };
@@ -44,13 +45,13 @@ size_t already_read, void *arg) { struct cbfs_mcache_build_args *args = arg; - union mcache_entry *entry = args->mcache; + union mcache_entry *entry = (void *)args->mcache; const uint32_t data_offset = be32toh(mdata->h.offset);
- if (args->end - args->mcache < data_offset) + if ((uintptr_t)args->end - (uintptr_t)args->mcache < data_offset) return CB_CBFS_CACHE_FULL;
- if (cbfs_copy_fill_metadata(args->mcache, mdata, already_read, dev, offset)) + if (cbfs_copy_fill_metadata((void *)args->mcache, mdata, already_read, dev, offset)) return CB_CBFS_IO;
entry->magic = MCACHE_MAGIC_FILE; @@ -66,15 +67,15 @@ struct vb2_hash *metadata_hash) { struct cbfs_mcache_build_args args = { - .mcache = mcache, - .end = mcache + ALIGN_DOWN(size, CBFS_MCACHE_ALIGNMENT) + .mcache = (uintptr_t)mcache, + .end = (uintptr_t)mcache + ALIGN_DOWN(size, CBFS_MCACHE_ALIGNMENT) - sizeof(uint32_t), /* leave space for terminating magic */ .count = 0, };
assert(size > sizeof(uint32_t) && IS_ALIGNED((uintptr_t)mcache, CBFS_MCACHE_ALIGNMENT)); enum cb_err ret = cbfs_walk(dev, build_walker, &args, metadata_hash, 0); - union mcache_entry *entry = args.mcache; + union mcache_entry *entry = (void *)args.mcache; if (ret == CB_CBFS_NOT_FOUND) { ret = CB_SUCCESS; entry->magic = MCACHE_MAGIC_END; @@ -84,7 +85,7 @@ }
LOG("mcache @%p built for %d files, used %#zx of %#zx bytes\n", mcache, - args.count, args.mcache + sizeof(entry->magic) - mcache, size); + args.count, args.mcache + sizeof(entry->magic) - (uintptr_t)mcache, size); return ret; }
@@ -92,11 +93,11 @@ union cbfs_mdata *mdata_out, size_t *data_offset_out) { const size_t namesize = strlen(name) + 1; /* Count trailing \0 so we can memcmp() it. */ - const void *end = mcache + mcache_size; - const void *current = mcache; + const uintptr_t end = (uintptr_t)mcache + mcache_size; + uintptr_t current = (uintptr_t)mcache;
while (current + sizeof(uint32_t) <= end) { - const union mcache_entry *entry = current; + const union mcache_entry *entry = (void *)current;
if (entry->magic == MCACHE_MAGIC_END) return CB_CBFS_NOT_FOUND; @@ -108,7 +109,7 @@ const uint32_t data_length = be32toh(entry->file.h.len); if (namesize <= data_offset - offsetof(union cbfs_mdata, h.filename) && memcmp(name, entry->file.h.filename, namesize) == 0) { - LOG("Found '%s' @%#x size %#x in mcache @%p\n", + LOG("Found '%s' @%#x size %#x in mcache @%lx\n", name, entry->offset, data_length, current); *data_offset_out = entry->offset + data_offset; memcpy(mdata_out, &entry->file, data_offset); @@ -124,11 +125,11 @@
size_t cbfs_mcache_real_size(const void *mcache, size_t mcache_size) { - const void *end = mcache + mcache_size; - const void *current = mcache; + const uintptr_t end = (uintptr_t)mcache + mcache_size; + uintptr_t current = (uintptr_t)mcache;
while (current + sizeof(uint32_t) <= end) { - const union mcache_entry *entry = current; + const union mcache_entry *entry = (void *)current;
if (entry->magic == MCACHE_MAGIC_FULL || entry->magic == MCACHE_MAGIC_END) { current += sizeof(entry->magic); @@ -139,5 +140,5 @@ current += ALIGN_UP(be32toh(entry->file.h.offset), CBFS_MCACHE_ALIGNMENT); }
- return current - mcache; + return current - (uintptr_t)mcache; } diff --git a/src/commonlib/bsd/cbfs_private.c b/src/commonlib/bsd/cbfs_private.c index e77c299..5ca6f29 100644 --- a/src/commonlib/bsd/cbfs_private.c +++ b/src/commonlib/bsd/cbfs_private.c @@ -2,6 +2,7 @@
#include <commonlib/bsd/cbfs_private.h> #include <assert.h> +#include <stdint.h>
static enum cb_err read_next_header(cbfs_dev_t dev, size_t *offset, struct cbfs_file *buffer, const size_t devsize) @@ -173,7 +174,7 @@ return NULL;
while (offset + sizeof(struct cbfs_file_attribute) <= end) { - const struct cbfs_file_attribute *attr = (const void *)mdata->raw + offset; + const struct cbfs_file_attribute *attr = (const void *)((uintptr_t)mdata->raw + offset); const uint32_t tag = be32toh(attr->tag); const uint32_t len = be32toh(attr->len);
diff --git a/src/commonlib/bsd/elog.c b/src/commonlib/bsd/elog.c index 8151d70..08465c0 100644 --- a/src/commonlib/bsd/elog.c +++ b/src/commonlib/bsd/elog.c @@ -3,6 +3,7 @@ #include <commonlib/bsd/bcd.h> #include <commonlib/bsd/elog.h> #include <stddef.h> +#include <stdint.h>
/* * verify and validate if header is a valid coreboot Event Log header. @@ -35,7 +36,7 @@ return NULL;
/* Point to next event */ - return (const struct event_header *)((const void *)(event) + event->length); + return (const struct event_header *)((uintptr_t)event + event->length); }
/* return the data associated to the event_header. */ diff --git a/src/commonlib/bsd/lz4_wrapper.c b/src/commonlib/bsd/lz4_wrapper.c index 73a3571..6c736c8 100644 --- a/src/commonlib/bsd/lz4_wrapper.c +++ b/src/commonlib/bsd/lz4_wrapper.c @@ -95,13 +95,14 @@
size_t ulz4fn(const void *src, size_t srcn, void *dst, size_t dstn) { - const void *in = src; + const uintptr_t src_ptr = (uintptr_t)src; + uintptr_t in = (uintptr_t)src; void *out = dst; size_t out_size = 0; int has_block_checksum;
{ /* With in-place decompression the header may become invalid later. */ - const struct lz4_frame_header *h = in; + const struct lz4_frame_header *h = (void *)in;
if (srcn < sizeof(*h) + sizeof(uint64_t) + sizeof(uint8_t)) return 0; /* input overrun */ @@ -123,7 +124,7 @@ }
while (1) { - if ((size_t)(in - src) + sizeof(struct lz4_block_header) > srcn) + if ((size_t)(in - src_ptr) + sizeof(struct lz4_block_header) > srcn) break; /* input overrun */
struct lz4_block_header b = { @@ -131,29 +132,29 @@ }; in += sizeof(struct lz4_block_header);
- if ((size_t)(in - src) + (b.raw & BH_SIZE) > srcn) + if ((size_t)(in - src_ptr) + (b.raw & BH_SIZE) > srcn) break; /* input overrun */
if (!(b.raw & BH_SIZE)) { - out_size = out - dst; + out_size = (uintptr_t)out - (uintptr_t)dst; break; /* decompression successful */ }
if (b.raw & NOT_COMPRESSED) { size_t size = MIN((uintptr_t)(b.raw & BH_SIZE), (uintptr_t)dst + dstn - (uintptr_t)out); - memcpy(out, in, size); + memcpy(out, (void *)in, size); if (size < (b.raw & BH_SIZE)) break; /* output overrun */ - out += size; + out = (void *)((uintptr_t)out + size); } else { /* constant folding essential, do not touch params! */ - int ret = LZ4_decompress_generic(in, out, (b.raw & BH_SIZE), - dst + dstn - out, endOnInputSize, + int ret = LZ4_decompress_generic((void *)in, out, (b.raw & BH_SIZE), + (uintptr_t)dst + dstn - (uintptr_t)out, endOnInputSize, full, 0, noDict, out, NULL, 0); if (ret < 0) break; /* decompression error */ - out += ret; + out = (void *)((uintptr_t)out + ret); }
in += (b.raw & BH_SIZE); diff --git a/src/cpu/x86/lapic/lapic_cpu_init.c b/src/cpu/x86/lapic/lapic_cpu_init.c index 2cb8459..c8b8a45 100644 --- a/src/cpu/x86/lapic/lapic_cpu_init.c +++ b/src/cpu/x86/lapic/lapic_cpu_init.c @@ -7,6 +7,7 @@ #include <acpi/acpi.h> #include <delay.h> #include <lib.h> +#include <stdint.h> #include <string.h> #include <symbols.h> #include <console/console.h> @@ -369,7 +370,7 @@ printk(BIOS_DEBUG, "All AP CPUs stopped (%ld loops)\n", loopcount); checkstack(_estack, 0); for (i = 1; i < CONFIG_MAX_CPUS && i <= last_cpu_index; i++) - checkstack((void *)stacks[i] + CONFIG_STACK_SIZE, i); + checkstack((void *)((uintptr_t)stacks[i] + CONFIG_STACK_SIZE), i); }
void initialize_cpus(struct bus *cpu_bus) diff --git a/src/cpu/x86/pae/pgtbl.c b/src/cpu/x86/pae/pgtbl.c index c8783d6..59c1da3 100644 --- a/src/cpu/x86/pae/pgtbl.c +++ b/src/cpu/x86/pae/pgtbl.c @@ -7,6 +7,7 @@ #include <cpu/x86/cr.h> #include <cpu/x86/msr.h> #include <cpu/x86/pae.h> +#include <stdint.h> #include <string.h> #include <symbols.h> #include <assert.h> @@ -201,7 +202,7 @@ printk(BIOS_SPEW, "%s: Clearing %llx[%lx] - %zx\n", __func__, dest + offset, (uintptr_t)vmem_addr + offset, len);
- memset(vmem_addr + offset, pat, len); + memset((void *)((uintptr_t)vmem_addr + offset), pat, len);
dest += s2MiB; length -= len; diff --git a/src/device/mmio.c b/src/device/mmio.c index de8c8d3..5487638 100644 --- a/src/device/mmio.c +++ b/src/device/mmio.c @@ -2,6 +2,7 @@
#include <assert.h> #include <device/mmio.h> +#include <stdint.h>
/* Helper functions for various MMIO access patterns. */
@@ -9,13 +10,14 @@ int fifo_stride, int fifo_width) { u8 *p = buffer; + u8 *f = fifo; int i, j;
assert(fifo_width > 0 && fifo_width <= sizeof(u32) && fifo_stride % sizeof(u32) == 0);
- for (i = 0; i < size; i += fifo_width, fifo += fifo_stride) { - u32 val = read32(fifo); + for (i = 0; i < size; i += fifo_width, f += fifo_stride) { + u32 val = read32(f); for (j = 0; j < MIN(size - i, fifo_width); j++) *p++ = (u8)(val >> (j * 8)); } @@ -31,7 +33,7 @@ fifo_stride % sizeof(u32) == 0 && prefsz <= fifo_width);
uint32_t val = prefix; - for (i = 0; i < size; i += fifo_width, fifo += fifo_stride) { + for (i = 0; i < size; i += fifo_width, fifo = (void *)((uintptr_t)fifo + fifo_stride)) { for (; j < MIN(size - i, fifo_width); j++) val |= *p++ << (j * 8); write32(fifo, val); diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c index b8dafd1..0e4e259 100644 --- a/src/device/pci_rom.c +++ b/src/device/pci_rom.c @@ -6,6 +6,7 @@ #include <device/pci.h> #include <device/pci_ids.h> #include <device/pci_ops.h> +#include <stdint.h> #include <stdio.h> #include <string.h> #include <cbfs.h> @@ -121,7 +122,7 @@ return NULL; }
- rom_data = (((void *)rom_header) + le32_to_cpu(rom_header->data)); + rom_data = (void *)(((uintptr_t)rom_header) + le32_to_cpu(rom_header->data));
printk(BIOS_SPEW, "PCI ROM image, vendor ID %04x, device ID %04x,\n", rom_data->vendor, rom_data->device); @@ -159,10 +160,10 @@
do { /* Get next image. */ - rom_header = (struct rom_header *)((void *) rom_header + rom_header = (struct rom_header *)((uintptr_t) rom_header + image_size);
- rom_data = (struct pci_data *)((void *) rom_header + rom_data = (struct pci_data *)((uintptr_t) rom_header + le32_to_cpu(rom_header->data));
image_size = le32_to_cpu(rom_data->ilen) * 512; @@ -197,8 +198,8 @@ rom_header, pci_ram_image_start, rom_size);
memcpy(pci_ram_image_start, rom_header, rom_size); - pci_ram_image_start += rom_size; - return (struct rom_header *) (pci_ram_image_start-rom_size); + pci_ram_image_start = (void *)((uintptr_t)pci_ram_image_start + rom_size); + return (struct rom_header *) ((uintptr_t)pci_ram_image_start-rom_size); }
/* ACPI */ diff --git a/src/drivers/mipi/panel.c b/src/drivers/mipi/panel.c index 9646eca..6b16409 100644 --- a/src/drivers/mipi/panel.c +++ b/src/drivers/mipi/panel.c @@ -3,6 +3,7 @@ #include <console/console.h> #include <delay.h> #include <mipi/panel.h> +#include <stdint.h>
enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func) { @@ -20,7 +21,7 @@ * For some commands like DELAY, the init->len should not be * counted for buf. */ - buf += sizeof(*init); + buf = (void *)((uintptr_t)buf + sizeof(*init));
u32 cmd = init->cmd, len = init->len;
@@ -71,7 +72,7 @@ enum cb_err ret = cmd_func(type, init->data, len); if (ret != CB_SUCCESS) return ret; - buf += len; + buf = (void *)((uintptr_t)buf + len); }
return CB_SUCCESS; diff --git a/src/drivers/spi/bitbang.c b/src/drivers/spi/bitbang.c index 168ec64..1c5b1b5 100644 --- a/src/drivers/spi/bitbang.c +++ b/src/drivers/spi/bitbang.c @@ -1,8 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include "device/mmio.h" #include <console/console.h> #include <delay.h> #include <spi_bitbang.h> +#include <stdint.h>
/* Set to 1 to dump all SPI transfers to the UART. */ #define TRACE 0 @@ -38,11 +40,13 @@ printk(BIOS_SPEW, ">"); }
+ uintptr_t dout_ptr = (uintptr_t)dout; + uintptr_t din_ptr = (uintptr_t)din; while (bytes_out || bytes_in) { int i; uint8_t in_byte = 0, out_byte = 0; if (bytes_out) { - out_byte = *(const uint8_t *)dout++; + out_byte = read8p(dout_ptr++); bytes_out--; if (TRACE) printk(BIOS_SPEW, "%02x", out_byte); @@ -58,7 +62,7 @@ ops->set_clk(ops, 0); } if (bytes_in) { - *(uint8_t *)din++ = in_byte; + write8p(din_ptr++, in_byte); bytes_in--; if (TRACE) printk(BIOS_SPEW, "%02x", in_byte); diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index c8ca14c..e30d906 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -13,6 +13,7 @@ #include <metadata_hash.h> #include <security/tpm/tspi/crtm.h> #include <security/vboot/vboot_common.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <symbols.h> @@ -546,8 +547,8 @@ return CB_ERR; prog_set_area(pstage, (void *)(uintptr_t)be64toh(sattr->loadaddr), be32toh(sattr->memlen)); - prog_set_entry(pstage, prog_start(pstage) + - be32toh(sattr->entry_offset), NULL); + prog_set_entry(pstage, (void *)((uintptr_t)prog_start(pstage) + + be32toh(sattr->entry_offset)), NULL);
/* Hacky way to not load programs over read only media. The stages * that would hit this path initialize themselves. */ @@ -565,7 +566,7 @@ compressed data to the end of the buffer and point &rdev to that memory location. */ if (cbfs_lz4_enabled() && compression == CBFS_COMPRESS_LZ4) { size_t in_size = region_device_sz(&rdev); - void *compr_start = prog_start(pstage) + prog_size(pstage) - in_size; + void *compr_start = (void *)((uintptr_t)prog_start(pstage) + prog_size(pstage) - in_size); if (rdev_readat(&rdev, compr_start, 0, in_size) != in_size) return CB_ERR; rdev_chain_mem(&rdev, compr_start, in_size); @@ -577,7 +578,7 @@ return CB_ERR;
/* Clear area not covered by file. */ - memset(prog_start(pstage) + fsize, 0, prog_size(pstage) - fsize); + memset((void *)((uintptr_t)prog_start(pstage) + fsize), 0, prog_size(pstage) - fsize);
prog_segment_loaded((uintptr_t)prog_start(pstage), prog_size(pstage), SEG_FINAL); diff --git a/src/lib/hexdump.c b/src/lib/hexdump.c index 533411f..da18baa 100644 --- a/src/lib/hexdump.c +++ b/src/lib/hexdump.c @@ -3,6 +3,7 @@ #include <console/console.h> #include <ctype.h> #include <lib.h> +#include <stdint.h>
void hexdump(const void *memory, size_t length) { @@ -33,7 +34,7 @@ }
if ((all_zero < 2) && (all_one < 2)) { - printk(BIOS_DEBUG, "%p:", memory + i); + printk(BIOS_DEBUG, "%lx:", (uintptr_t)memory + i); for (j = 0; j < num_bytes; j++) printk(BIOS_DEBUG, " %02x", line[j]); for (; j < 16; j++) diff --git a/src/lib/lzma.c b/src/lib/lzma.c index d2e3e4b..cf8d323 100644 --- a/src/lib/lzma.c +++ b/src/lib/lzma.c @@ -15,6 +15,7 @@ #include <lib.h>
#include "lzmadecode.h" +#include "stddef.h"
size_t ulzman(const void *src, size_t srcn, void *dst, size_t dstn) { @@ -39,7 +40,7 @@ * (ref: lzma.cc@LZMACompress: put_64). To prevent accessing by * unaligned memory address and to load in correct endianness, read each * byte and re-construct. */ - cp = src + LZMA_PROPERTIES_SIZE; + cp = (unsigned char *)src + LZMA_PROPERTIES_SIZE; outSize = cp[3] << 24 | cp[2] << 16 | cp[1] << 8 | cp[0]; if (outSize > dstn) outSize = dstn; @@ -54,7 +55,7 @@ return 0; } state.Probs = (CProb *)scratchpad; - res = LzmaDecode(&state, src + data_offset, srcn - data_offset, + res = LzmaDecode(&state, (unsigned char *)src + data_offset, srcn - data_offset, &inProcessed, dst, outSize, &outProcessed); if (res != 0) { printk(BIOS_WARNING, "lzma: Decoding error = %d\n", res); diff --git a/src/lib/malloc.c b/src/lib/malloc.c index 7d787d6..9aebb2d 100644 --- a/src/lib/malloc.c +++ b/src/lib/malloc.c @@ -1,4 +1,5 @@ #include <console/console.h> +#include <stdint.h> #include <stdlib.h> #include <string.h>
@@ -27,7 +28,7 @@ free_mem_ptr = (void *)ALIGN((unsigned long)free_mem_ptr, boundary);
p = free_mem_ptr; - free_mem_ptr += size; + free_mem_ptr = (void *)((uintptr_t)free_mem_ptr + size); /* * Store last allocation pointer after ALIGN, as malloc() will * return it. This may cause n bytes of gap between allocations diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c index 31bf141..6437ec6 100644 --- a/src/lib/rmodule.c +++ b/src/lib/rmodule.c @@ -264,7 +264,7 @@ if (rmodule_parse(rmod_loc, &rmod_stage)) return -1;
- if (rmodule_load(rmod_loc + sizeof(struct rmodule_header), &rmod_stage)) + if (rmodule_load((void *)((uintptr_t)rmod_loc + sizeof(struct rmodule_header)), &rmod_stage)) return -1;
prog_set_area(rsl->prog, rmod_stage.location, diff --git a/src/lib/stack.c b/src/lib/stack.c index 479ed93..ae364a1 100644 --- a/src/lib/stack.c +++ b/src/lib/stack.c @@ -25,6 +25,7 @@ #include <assert.h> #include <lib.h> #include <console/console.h> +#include <stdint.h> #include <symbols.h>
int checkstack(void *top_of_stack, int core) @@ -33,7 +34,7 @@ size_t stack_size = CONFIG_STACK_SIZE ? CONFIG_STACK_SIZE : REGION_SIZE(stack); int i; - u32 *stack = (u32 *) (top_of_stack - stack_size); + u32 *stack = (u32 *) ((uintptr_t)top_of_stack - stack_size);
if (stack[0] != 0xDEADBEEF) { printk(BIOS_ERR,