Commit 155b7352 authored by Uros Bizjak's avatar Uros Bizjak Committed by H. Peter Anvin

x86: Fix movq immediate operand constraints in uaccess_64.h

arch/x86/include/asm/uaccess_64.h uses wrong asm operand constraint
("ir") for movq insn. Since movq sign-extends its immediate operand,
"er" constraint should be used instead.

Attached patch changes all uses of __put_user_asm in uaccess_64.h to use
"er" when "q" insn suffix is involved.

Patch was compile tested on x86_64 with defconfig.
Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
Cc: stable@kernel.org
parent 77f32dfd
...@@ -88,11 +88,11 @@ int __copy_to_user(void __user *dst, const void *src, unsigned size) ...@@ -88,11 +88,11 @@ int __copy_to_user(void __user *dst, const void *src, unsigned size)
ret, "l", "k", "ir", 4); ret, "l", "k", "ir", 4);
return ret; return ret;
case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst, case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
ret, "q", "", "ir", 8); ret, "q", "", "er", 8);
return ret; return ret;
case 10: case 10:
__put_user_asm(*(u64 *)src, (u64 __user *)dst, __put_user_asm(*(u64 *)src, (u64 __user *)dst,
ret, "q", "", "ir", 10); ret, "q", "", "er", 10);
if (unlikely(ret)) if (unlikely(ret))
return ret; return ret;
asm("":::"memory"); asm("":::"memory");
...@@ -101,12 +101,12 @@ int __copy_to_user(void __user *dst, const void *src, unsigned size) ...@@ -101,12 +101,12 @@ int __copy_to_user(void __user *dst, const void *src, unsigned size)
return ret; return ret;
case 16: case 16:
__put_user_asm(*(u64 *)src, (u64 __user *)dst, __put_user_asm(*(u64 *)src, (u64 __user *)dst,
ret, "q", "", "ir", 16); ret, "q", "", "er", 16);
if (unlikely(ret)) if (unlikely(ret))
return ret; return ret;
asm("":::"memory"); asm("":::"memory");
__put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst, __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
ret, "q", "", "ir", 8); ret, "q", "", "er", 8);
return ret; return ret;
default: default:
return copy_user_generic((__force void *)dst, src, size); return copy_user_generic((__force void *)dst, src, size);
...@@ -157,7 +157,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size) ...@@ -157,7 +157,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
ret, "q", "", "=r", 8); ret, "q", "", "=r", 8);
if (likely(!ret)) if (likely(!ret))
__put_user_asm(tmp, (u64 __user *)dst, __put_user_asm(tmp, (u64 __user *)dst,
ret, "q", "", "ir", 8); ret, "q", "", "er", 8);
return ret; return ret;
} }
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment