cache: Fix cache API calling from userspace

When a cache API function is called from userspace, this results on
ARM64 in an OOPS (bad syscall error). This is due to at least two
different factors:

- the location of the cache handlers is preventing the linker to
  actually find the handlers
- specifically for ARM64 and ARC some cache handling functions are not
  implemented (when userspace is not used the compiler simply optimizes
  out these calls)

Fix the problem by:

- moving the userspace cache handlers to a their logical and proper
  location (in the drivers directory)
- adding the missing handlers for ARM64 and ARC

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2022-08-22 12:06:25 +02:00 committed by Carles Cufí
parent 318bfce8fb
commit 4806e1087e
5 changed files with 30 additions and 5 deletions

View file

@ -139,6 +139,21 @@ int arch_dcache_range(void *addr, size_t size, int op)
return 0; return 0;
} }
int arch_icache_range(void *addr, size_t size, int op)
{
return -ENOTSUP;
}
int arch_dcache_all(int op)
{
return -ENOTSUP;
}
int arch_icache_all(int op)
{
return -ENOTSUP;
}
#if defined(CONFIG_DCACHE_LINE_SIZE_DETECT) #if defined(CONFIG_DCACHE_LINE_SIZE_DETECT)
static void init_dcache_line_size(void) static void init_dcache_line_size(void)
{ {

View file

@ -206,3 +206,13 @@ int arch_dcache_all(int op)
return 0; return 0;
} }
int arch_icache_range(void *addr, size_t size, int op)
{
return -ENOTSUP;
}
int arch_icache_all(int op)
{
return -ENOTSUP;
}

View file

@ -1,2 +1,6 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
zephyr_sources_ifdef(CONFIG_CACHE_ASPEED cache_aspeed.c)
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_CACHE_ASPEED cache_aspeed.c)
zephyr_library_sources_ifdef(CONFIG_USERSPACE cache_handlers.c)

View file

@ -101,10 +101,6 @@ target_sources_ifdef(
userspace.c userspace.c
) )
if(CONFIG_CACHE_MANAGEMENT AND CONFIG_USERSPACE)
target_sources(kernel PRIVATE cache_handlers.c)
endif()
target_include_directories(kernel PRIVATE target_include_directories(kernel PRIVATE
${ZEPHYR_BASE}/kernel/include ${ZEPHYR_BASE}/kernel/include
${ARCH_DIR}/${ARCH}/include ${ARCH_DIR}/${ARCH}/include