[PATCH v8 23/30] powerpc: Add prefixed instructions to instruction data type
Jordan Niethe
jniethe5 at gmail.com
Thu May 14 11:40:55 AEST 2020
Hi mpe,
Relating to your message on [PATCH v8 16/30] powerpc: Define and use
__get_user_instr{,inatomic}() - could you please take this.
diff --git a/arch/powerpc/include/asm/uaccess.h
b/arch/powerpc/include/asm/uaccess.h
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -106,6 +106,24 @@ static inline int __access_ok(unsigned long addr,
unsigned long size,
__put_user_nosleep((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
#ifdef __powerpc64__
+#define get_user_instr(x, ptr) \
+({ \
+ long __gui_ret = 0; \
+ unsigned long __gui_ptr = (unsigned long)ptr; \
+ struct ppc_inst __gui_inst; \
+ unsigned int prefix, suffix; \
+ __gui_ret = get_user(prefix, (unsigned int __user *)__gui_ptr); \
+ if (!__gui_ret && (prefix >> 26) == OP_PREFIX) { \
+ __gui_ret = get_user(suffix, \
+ (unsigned int __user *)__gui_ptr + 1); \
+ __gui_inst = ppc_inst_prefix(prefix, suffix); \
+ } else { \
+ __gui_inst = ppc_inst(prefix); \
+ } \
+ (x) = __gui_inst; \
+ __gui_ret; \
+})
+
#define __get_user_instr(x, ptr) \
({ \
long __gui_ret = 0; \
@@ -142,6 +160,8 @@ static inline int __access_ok(unsigned long addr,
unsigned long size,
__gui_ret; \
})
#else
+#define get_user_instr(x, ptr) \
+ get_user((x).val, (u32 *)(ptr))
#define __get_user_instr(x, ptr) \
__get_user_nocheck((x).val, (u32 *)(ptr), sizeof(u32), true)
#define __get_user_instr_inatomic(x, ptr) \
More information about the Linuxppc-dev
mailing list