mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
While the GCC and Clang compilers already define __ASSEMBLER__ automatically when compiling assembly code, __ASSEMBLY__ is a macro that only gets defined by the Makefiles in the kernel. This can be very confusing when switching between userspace and kernelspace coding, or when dealing with uapi headers that rather should use __ASSEMBLER__ instead. So let's standardize now on the __ASSEMBLER__ macro that is provided by the compilers. This is a mostly mechanical patch (done with a simple "sed -i" statement), except for the following files where comments with mis-spelled macros were tweaked manually: arch/arm64/include/asm/stacktrace/frame.h arch/arm64/include/asm/kvm_ptrauth.h arch/arm64/include/asm/debug-monitors.h arch/arm64/include/asm/esr.h arch/arm64/include/asm/scs.h arch/arm64/include/asm/memory.h Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
39 lines
1011 B
C
39 lines
1011 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef __ASM_VDSO_GETRANDOM_H
|
|
#define __ASM_VDSO_GETRANDOM_H
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
#include <asm/unistd.h>
|
|
#include <asm/vdso/vsyscall.h>
|
|
#include <vdso/datapage.h>
|
|
|
|
/**
|
|
* getrandom_syscall - Invoke the getrandom() syscall.
|
|
* @buffer: Destination buffer to fill with random bytes.
|
|
* @len: Size of @buffer in bytes.
|
|
* @flags: Zero or more GRND_* flags.
|
|
* Returns: The number of random bytes written to @buffer, or a negative value indicating an error.
|
|
*/
|
|
static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsigned int _flags)
|
|
{
|
|
register void *buffer asm ("x0") = _buffer;
|
|
register size_t len asm ("x1") = _len;
|
|
register unsigned int flags asm ("x2") = _flags;
|
|
register long ret asm ("x0");
|
|
register long nr asm ("x8") = __NR_getrandom;
|
|
|
|
asm volatile(
|
|
" svc #0\n"
|
|
: "=r" (ret)
|
|
: "r" (buffer), "r" (len), "r" (flags), "r" (nr)
|
|
: "memory");
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* !__ASSEMBLER__ */
|
|
|
|
#endif /* __ASM_VDSO_GETRANDOM_H */
|