mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-07 18:40:10 +00:00
Provide a __copy_from_user that uses memcpy. On BCM2708, use optimised memcpy/memmove/memcmp/memset implementations. arch/arm: Add mmiocpy/set aliases for memcpy/set See: https://github.com/raspberrypi/linux/issues/1082 copy_from_user: CPU_SW_DOMAIN_PAN compatibility The downstream copy_from_user acceleration must also play nice with CONFIG_CPU_SW_DOMAIN_PAN. See: https://github.com/raspberrypi/linux/issues/1381 Signed-off-by: Phil Elwell <phil@raspberrypi.org> Fix copy_from_user if BCM2835_FAST_MEMCPY=n The change which introduced CONFIG_BCM2835_FAST_MEMCPY unconditionally changed the behaviour of arm_copy_from_user. The page pinning code is not safe on ARMv7 if LPAE & high memory is enabled and causes crashes which look like PTE corruption. Make __copy_from_user_memcpy conditional on CONFIG_2835_FAST_MEMCPY=y which is really an ARMv6 / Pi1 optimization and not necessary on newer ARM processors. arm: fix mmap unlocks in uaccess_with_memcpy.c This is a regression that was added with the commit192a4e923eas of rpi-5.8.y, since that is when the move to the mmap locking API was introduced -d8ed45c5dcThe issue is that when the patch to improve performance for the __copy_to_user and __copy_from_user functions were added for the Raspberry Pi, some of the mmaps were incorrectly mapped to write instead of read. This would cause a verity of issues, and in my case, prevent the booting of a squashfs filesystem on rpi-5.8-y and above. An example of the panic you would see from this can be seen at https://pastebin.com/raw/jBz5xCzL Signed-off-by: Christian Lamparter <chunkeey@gmail.com> Signed-off-by: Christopher Blake <chrisrblake93@gmail.com> arch/arm: Add __memset alias to memset_rpi.S memset_rpi.S is an optimised memset implementation, but doesn't define __memset (which was just added to memset.S). As a result, building for the BCM2835 platform causes a link failure. Add __memset as yet another alias to our common implementation. Signed-off-by: Phil Elwell <phil@raspberrypi.com> arm: Fix custom rpi __memset32 and __memset64 See: https://github.com/raspberrypi/linux/issues/4798 Signed-off-by: Phil Elwell <phil@raspberrypi.com> arm: Fix annoying .eh_frame section warnings Replace the cfi directives with the UNWIND equivalents. This prevents the .eh_frame section from being created, eliminating the warnings. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
74 lines
2.2 KiB
C
74 lines
2.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_ARM_STRING_H
|
|
#define __ASM_ARM_STRING_H
|
|
|
|
/*
|
|
* We don't do inline string functions, since the
|
|
* optimised inline asm versions are not small.
|
|
*
|
|
* The __underscore versions of some functions are for KASan to be able
|
|
* to replace them with instrumented versions.
|
|
*/
|
|
|
|
#define __HAVE_ARCH_STRRCHR
|
|
extern char * strrchr(const char * s, int c);
|
|
|
|
#define __HAVE_ARCH_STRCHR
|
|
extern char * strchr(const char * s, int c);
|
|
|
|
#define __HAVE_ARCH_MEMCPY
|
|
extern void * memcpy(void *, const void *, __kernel_size_t);
|
|
extern void *__memcpy(void *dest, const void *src, __kernel_size_t n);
|
|
|
|
#define __HAVE_ARCH_MEMMOVE
|
|
extern void * memmove(void *, const void *, __kernel_size_t);
|
|
extern void *__memmove(void *dest, const void *src, __kernel_size_t n);
|
|
|
|
#define __HAVE_ARCH_MEMCHR
|
|
extern void * memchr(const void *, int, __kernel_size_t);
|
|
|
|
#define __HAVE_ARCH_MEMSET
|
|
extern void * memset(void *, int, __kernel_size_t);
|
|
extern void *__memset(void *s, int c, __kernel_size_t n);
|
|
|
|
#define __HAVE_ARCH_MEMSET32
|
|
extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
|
|
static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
|
|
{
|
|
return __memset32(p, v, n * 4);
|
|
}
|
|
|
|
#define __HAVE_ARCH_MEMSET64
|
|
extern void *__memset64(uint64_t *, uint32_t low, __kernel_size_t, uint32_t hi);
|
|
static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
|
|
{
|
|
return __memset64(p, v, n * 8, v >> 32);
|
|
}
|
|
|
|
/*
|
|
* For files that are not instrumented (e.g. mm/slub.c) we
|
|
* must use non-instrumented versions of the mem*
|
|
* functions named __memcpy() etc. All such kernel code has
|
|
* been tagged with KASAN_SANITIZE_file.o = n, which means
|
|
* that the address sanitization argument isn't passed to the
|
|
* compiler, and __SANITIZE_ADDRESS__ is not set. As a result
|
|
* these defines kick in.
|
|
*/
|
|
#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
|
|
#define memcpy(dst, src, len) __memcpy(dst, src, len)
|
|
#define memmove(dst, src, len) __memmove(dst, src, len)
|
|
#define memset(s, c, n) __memset(s, c, n)
|
|
|
|
#ifndef __NO_FORTIFY
|
|
#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_BCM2835_FAST_MEMCPY
|
|
#define __HAVE_ARCH_MEMCMP
|
|
extern int memcmp(const void *, const void *, size_t);
|
|
#endif
|
|
|
|
#endif
|