aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Singh Tomar <abhishek@linux.ibm.com>2022-01-24 19:26:12 +0530
committerCédric Le Goater <clg@kaod.org>2022-02-04 08:35:25 +0100
commita9bc782c843250a17255236acc210fbbe16ddf78 (patch)
treea1e47431d10c638dea932bc3574d38f4365e482e
parent095cef27f0f4aad58266516846e65363418cf7f1 (diff)
downloadskiboot-a9bc782c843250a17255236acc210fbbe16ddf78.zip
skiboot-a9bc782c843250a17255236acc210fbbe16ddf78.tar.gz
skiboot-a9bc782c843250a17255236acc210fbbe16ddf78.tar.bz2
Fix array-bound compilation warnings
Resolves : the warray bounds warning during compilation /build/libc/include/string.h:34:16: warning: '__builtin_memset' offset [0, 2097151] is out of the bounds [0, 0] [-Warray-bounds] 34 | #define memset __builtin_memset hw/fsp/fsp.c:1855:9: note: in expansion of macro 'memset' 1855 | memset(fsp_tce_table, 0, PSI_TCE_TABLE_SIZE); use volatile pointer to avoid optimization introduced with gcc-11 on constant address assignment to pointer. Signed-off-by: Abhishek Singh Tomar <abhishek@linux.ibm.com> Signed-off-by: Cédric Le Goater <clg@kaod.org>
-rw-r--r--core/console.c2
-rw-r--r--core/fast-reboot.c6
-rw-r--r--core/init.c6
-rw-r--r--core/opal-dump.c7
-rw-r--r--hdata/spira.c2
-rw-r--r--hdata/spira.h2
-rw-r--r--hw/fsp/fsp.c2
-rw-r--r--include/compiler.h12
8 files changed, 29 insertions, 10 deletions
diff --git a/core/console.c b/core/console.c
index 2a15090..374ee03 100644
--- a/core/console.c
+++ b/core/console.c
@@ -15,7 +15,7 @@
#include <processor.h>
#include <cpu.h>
-static char *con_buf = (char *)INMEM_CON_START;
+static char *skiboot_constant_addr con_buf = (char *)INMEM_CON_START;
static size_t con_in;
static size_t con_out;
static bool con_wrapped;
diff --git a/core/fast-reboot.c b/core/fast-reboot.c
index fedfa88..6f6ef3a 100644
--- a/core/fast-reboot.c
+++ b/core/fast-reboot.c
@@ -307,6 +307,8 @@ void __noreturn fast_reboot_entry(void);
void __noreturn fast_reboot_entry(void)
{
struct cpu_thread *cpu = this_cpu();
+ void *skiboot_constant_addr kerneal_load_base_addr = KERNEL_LOAD_BASE;
+ void *skiboot_constant_addr initramfs_load_base_addr = INITRAMFS_LOAD_BASE;
if (proc_gen == proc_gen_p8) {
/* We reset our ICP first ! Otherwise we might get stray
@@ -425,8 +427,8 @@ void __noreturn fast_reboot_entry(void)
* Mambo may have embedded payload here, so don't clear
* it at all.
*/
- memset(KERNEL_LOAD_BASE, 0, KERNEL_LOAD_SIZE);
- memset(INITRAMFS_LOAD_BASE, 0, INITRAMFS_LOAD_SIZE);
+ memset(kerneal_load_base_addr, 0, KERNEL_LOAD_SIZE);
+ memset(initramfs_load_base_addr, 0, INITRAMFS_LOAD_SIZE);
}
/* Start preloading kernel and ramdisk */
diff --git a/core/init.c b/core/init.c
index b4d3351..a1fd5f2 100644
--- a/core/init.c
+++ b/core/init.c
@@ -869,7 +869,11 @@ void copy_exception_vectors(void)
* this is the boot flag used by CPUs still potentially entering
* skiboot.
*/
- memcpy((void *)0x100, (void *)(SKIBOOT_BASE + 0x100),
+ void *skiboot_constant_addr exception_vectors_start_addr = (void *)(SKIBOOT_BASE + 0x100);
+ void *skiboot_constant_addr dst = (void *)0x100;
+
+
+ memcpy(dst, exception_vectors_start_addr,
EXCEPTION_VECTORS_END - 0x100);
sync_icache();
}
diff --git a/core/opal-dump.c b/core/opal-dump.c
index 4f54a3e..577a906 100644
--- a/core/opal-dump.c
+++ b/core/opal-dump.c
@@ -301,6 +301,7 @@ static int64_t opal_mpipl_update(enum opal_mpipl_ops ops,
u64 src, u64 dest, u64 size)
{
int rc;
+ void *skiboot_constant_addr mdrt_table_base_addr = (void *) MDRT_TABLE_BASE;
switch (ops) {
case OPAL_MPIPL_ADD_RANGE:
@@ -330,7 +331,7 @@ static int64_t opal_mpipl_update(enum opal_mpipl_ops ops,
free(opal_mpipl_cpu_data);
opal_mpipl_cpu_data = NULL;
/* Clear MDRT table */
- memset((void *)MDRT_TABLE_BASE, 0, MDRT_TABLE_SIZE);
+ memset(mdrt_table_base_addr, 0, MDRT_TABLE_SIZE);
/* Set MDRT count to max allocated count */
ntuple_mdrt->act_cnt = cpu_to_be16(MDRT_TABLE_SIZE / sizeof(struct mdrt_table));
rc = OPAL_SUCCESS;
@@ -529,8 +530,8 @@ bool is_mpipl_enabled(void)
void opal_mpipl_init(void)
{
- void *mdst_base = (void *)MDST_TABLE_BASE;
- void *mddt_base = (void *)MDDT_TABLE_BASE;
+ void *skiboot_constant_addr mdst_base = (void *)MDST_TABLE_BASE;
+ void *skiboot_constant_addr mddt_base = (void *)MDDT_TABLE_BASE;
struct dt_node *dump_node;
dump_node = dt_find_by_path(opal_node, "dump");
diff --git a/hdata/spira.c b/hdata/spira.c
index 1a35146..fbb14b0 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -236,7 +236,7 @@ __section(".spirah.data") struct spirah spirah = {
};
/* The service processor SPIRA-S structure */
-struct spiras *spiras;
+struct spiras *skiboot_constant_addr spiras;
/* Overridden for testing. */
#ifndef spira_check_ptr
diff --git a/hdata/spira.h b/hdata/spira.h
index 8def23b..c0eb2a0 100644
--- a/hdata/spira.h
+++ b/hdata/spira.h
@@ -150,7 +150,7 @@ struct spiras {
u8 reserved[0x180];
} __packed __align(0x100);
-extern struct spiras *spiras;
+extern struct spiras *skiboot_constant_addr spiras;
/* This macro can be used to check the validity of a pointer returned
diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c
index 2c5f9d7..2fd9e5f 100644
--- a/hw/fsp/fsp.c
+++ b/hw/fsp/fsp.c
@@ -91,7 +91,7 @@ static enum ipl_state ipl_state = ipl_initial;
static struct fsp *first_fsp;
static struct fsp *active_fsp;
static u16 fsp_curseq = 0x8000;
-static __be64 *fsp_tce_table;
+static __be64 *skiboot_constant_addr fsp_tce_table;
#define FSP_INBOUND_SIZE 0x00100000UL
static void *fsp_inbound_buf = NULL;
diff --git a/include/compiler.h b/include/compiler.h
index a9ccfae..77821ec 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -38,4 +38,16 @@ static inline void barrier(void)
#define __tostr(x) #x
#define tostr(x) __tostr(x)
+
+#if __GNUC__ >= 11
+/* Compiler workaround to avoid compiler optimization warnings
+ * when assigning constant address to pointer and using memory
+ * functions such as memcpy and memset
+ */
+#define skiboot_constant_addr volatile
+#else
+#define skiboot_constant_addr
+#endif
+
+
#endif /* __COMPILER_H */