Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions arch/riscv/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,21 @@ do { \

#endif /* CONFIG_64BIT */

unsigned long __must_check __asm_copy_to_user(void __user *to,
const void *from, unsigned long n);
unsigned long __must_check __asm_copy_from_user(void *to,
const void __user *from, unsigned long n);

#define __get_user_nocheck(x, __gu_ptr, label) \
do { \
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) { \
if (!IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) { \
if (__asm_copy_from_user(&(x), __gu_ptr, sizeof(*__gu_ptr))) \
goto label; \
else \
break; \
} \
} \
switch (sizeof(*__gu_ptr)) { \
case 1: \
__get_user_asm("lb", (x), __gu_ptr, label); \
Expand Down Expand Up @@ -297,6 +310,15 @@ do { \

#define __put_user_nocheck(x, __gu_ptr, label) \
do { \
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) { \
if (!IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) { \
unsigned long val = (unsigned long)(x); \
if (__asm_copy_to_user(__gu_ptr, &(val), sizeof(*__gu_ptr))) \
goto label; \
else \
break; \
} \
} \
switch (sizeof(*__gu_ptr)) { \
case 1: \
__put_user_asm("sb", (x), __gu_ptr, label); \
Expand Down Expand Up @@ -385,12 +407,6 @@ err_label: \
-EFAULT; \
})


unsigned long __must_check __asm_copy_to_user(void __user *to,
const void *from, unsigned long n);
unsigned long __must_check __asm_copy_from_user(void *to,
const void __user *from, unsigned long n);

static inline unsigned long
raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int get_unalign_ctl(struct task_struct *tsk, unsigned long adr)
if (!unaligned_ctl_available())
return -EINVAL;

return put_user(tsk->thread.align_ctl, (unsigned long __user *)adr);
return put_user(tsk->thread.align_ctl, (unsigned int __user *)adr);
}

void __show_regs(struct pt_regs *regs)
Expand Down
Loading