From 7181a6d1cf71b9e97cfcf175400390f9eabde8a8 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 22 Jan 2019 19:33:59 +0300 Subject: ARC: Fix iteration in arc_xx_version() "i" gets incremented before we're entering loop body and effectively we iterate from 1 to 8 instead of 0 to 7. This way we: a) Skip the first line of struct hs_versions b) Go over it and access memory beyond the structure Signed-off-by: Alexey Brodkin --- arch/arc/lib/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c index 07daaa8d155..01cca95d5b1 100644 --- a/arch/arc/lib/cpu.c +++ b/arch/arc/lib/cpu.c @@ -87,7 +87,7 @@ const char *arc_em_version(int arcver, char *name, int name_len) bool xymem = ARC_FEATURE_EXISTS(ARC_AUX_XY_BUILD); int i; - for (i = 0; i++ < sizeof(em_versions) / sizeof(struct em_template_t);) { + for (i = 0; i < sizeof(em_versions) / sizeof(struct em_template_t); i++) { if (em_versions[i].cache == cache && em_versions[i].dsp == dsp && em_versions[i].xymem == xymem) { @@ -147,7 +147,7 @@ const char *arc_hs_version(int arcver, char *name, int name_len) bool dual_issue = arcver == 0x54 ? true : false; int i; - for (i = 0; i++ < sizeof(hs_versions) / sizeof(struct hs_template_t);) { + for (i = 0; i < sizeof(hs_versions) / sizeof(struct hs_template_t); i++) { if (hs_versions[i].cache == cache && hs_versions[i].mmu == mmu && hs_versions[i].dual_issue == dual_issue && -- cgit v1.2.3 From fae3798ac9f6de5a4cb1aa1e849d419a2bb8dbbe Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 22 Jan 2019 19:37:15 +0300 Subject: ARC: cache: define CONFIG_SYS_CACHELINE_SIZE as ARCH_DMA_MINALIGN Even though we don't use CONFIG_SYS_CACHELINE_SIZE in ARC-specific code it is used a lot in different drivers for alignment purposes. So we define it and make much more drivers at least compilable for ARC. Signed-off-by: Alexey Brodkin --- arch/arc/include/asm/cache.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch') diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index 1604cd0b3e7..0fdcf2d2dd5 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h @@ -16,6 +16,9 @@ */ #define ARCH_DMA_MINALIGN 128 +/* CONFIG_SYS_CACHELINE_SIZE is used a lot in drivers */ +#define CONFIG_SYS_CACHELINE_SIZE ARCH_DMA_MINALIGN + #if defined(ARC_MMU_ABSENT) #define CONFIG_ARC_MMU_VER 0 #elif defined(CONFIG_ARC_MMU_V2) -- cgit v1.2.3