cpu/x86/smm: Fix uintptr_t type mismatches in print statements
The 64-bit compiler x86_64-linux-gnu-gcc-10 aborts the build with the
format warning below:
CC ramstage/cpu/x86/smm/smm_module_loader.o
src/cpu/x86/smm/smm_module_loader.c: In function 'smm_create_map':
src/cpu/x86/smm/smm_module_loader.c:146:19: error: format '%zx' expects argument of type 'size_t', but argument 3 has type 'uintptr_t' {aka 'long unsigned int'} [-Werror=format=]
146 | " smbase %zx entry %zx\n",
| ~~^
| |
| unsigned int
| %lx
147 | cpus[i].smbase, cpus[i].entry);
| ~~~~~~~~~~~~~~
| |
| uintptr_t {aka long unsigned int}
In coreboot `uintptr_t` is defined in `src/include/stdint.h`:
typedef unsigned long uintptr_t;
As `size_t` is defined as `long unsigned int` in i386-elf (32-bit), the
length modifier `z` matches there. With x86_64-elf/x86_64-linux-gnu
(64-bit) and `-m32` `size_t` is defined as `unsigned int` resulting in a
type mismatch. Normally, `PRIxPTR` would need to be used as a length
modifier, but as coreboot always defines `uintptr_t` to `unsigned long`
(and in `src/include/inttypes.h` also defines `PRIxPTR` as `"lx"`), use
the length modifier `l` to make the code more readable.
Found-by: x86_64-linux-gnu-gcc-10 (Debian 10.2.1-6) 10.2.1 20210110
Fixes: afb7a814 ("cpu/x86/smm: Introduce SMM module loader version 2")
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Change-Id: I32bff397c8a033fe34390e6c1a7dfe773707a4e8
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54341
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c
index e3b8417..6d999a7 100644
--- a/src/cpu/x86/smm/smm_module_loader.c
+++ b/src/cpu/x86/smm/smm_module_loader.c
@@ -143,10 +143,10 @@
for (i = 0; i < num_cpus; i++) {
printk(BIOS_DEBUG, "CPU 0x%x\n", i);
printk(BIOS_DEBUG,
- " smbase %zx entry %zx\n",
+ " smbase %lx entry %lx\n",
cpus[i].smbase, cpus[i].entry);
printk(BIOS_DEBUG,
- " ss_start %zx code_end %zx\n",
+ " ss_start %lx code_end %lx\n",
cpus[i].ss_start, cpus[i].code_end);
seg_count++;
if (seg_count >= cpus_in_segment) {
@@ -217,13 +217,13 @@
if (cpus[num_cpus].active) {
if (cpus[num_cpus - 1].smbase + SMM_ENTRY_OFFSET < stack_top) {
printk(BIOS_ERR, "%s: stack encroachment\n", __func__);
- printk(BIOS_ERR, "%s: smbase %zx, stack_top %lx\n",
+ printk(BIOS_ERR, "%s: smbase %lx, stack_top %lx\n",
__func__, cpus[num_cpus].smbase, stack_top);
return 0;
}
}
- printk(BIOS_INFO, "%s: smbase %zx, stack_top %lx\n",
+ printk(BIOS_INFO, "%s: smbase %lx, stack_top %lx\n",
__func__, cpus[num_cpus-1].smbase, stack_top);
/* start at 1, the first CPU stub code is already there */
@@ -231,9 +231,9 @@
for (i = 1; i < num_cpus; i++) {
memcpy((int *)cpus[i].code_start, (int *)cpus[0].code_start, size);
printk(BIOS_DEBUG,
- "SMM Module: placing smm entry code at %zx, cpu # 0x%x\n",
+ "SMM Module: placing smm entry code at %lx, cpu # 0x%x\n",
cpus[i].code_start, i);
- printk(BIOS_DEBUG, "%s: copying from %zx to %zx 0x%x bytes\n",
+ printk(BIOS_DEBUG, "%s: copying from %lx to %lx 0x%x bytes\n",
__func__, cpus[0].code_start, cpus[i].code_start, size);
}
return 1;