提交 da2cf6dc 编写于 作者: Y Youling Tang 提交者: Hongchen Zhang

LoongArch: Consolidate __ex_table construction

mainline inclusion
from mainline-v6.2-rc1
commit 508f28c6
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6BWFP
CVE: NA

--------------------------------

Consolidate all the __ex_table constuction code with a _ASM_EXTABLE or
_asm_extable helper.

There should be no functional change as a result of this patch.
Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
Change-Id: I24db0d24f7ec183f687221f9d99c4eb8f17cebd2
上级 b8690293
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __ASM_ASM_EXTABLE_H
#define __ASM_ASM_EXTABLE_H
#ifdef __ASSEMBLY__
#define __ASM_EXTABLE_RAW(insn, fixup) \
.pushsection __ex_table, "a"; \
.balign 8; \
.quad (insn); \
.quad (fixup); \
.popsection;
.macro _asm_extable, insn, fixup
__ASM_EXTABLE_RAW(\insn, \fixup)
.endm
#else /* __ASSEMBLY__ */
#include <linux/bits.h>
#include <linux/stringify.h>
#define __ASM_EXTABLE_RAW(insn, fixup) \
".pushsection __ex_table, \"a\"\n" \
".balign 8\n" \
".quad ((" insn "))\n" \
".quad ((" fixup "))\n" \
".popsection\n"
#define _ASM_EXTABLE(insn, fixup) \
__ASM_EXTABLE_RAW(#insn, #fixup)
#endif /* __ASSEMBLY__ */
#endif /* __ASM_ASM_EXTABLE_H */
......@@ -7,6 +7,7 @@
#include <linux/futex.h>
#include <linux/uaccess.h>
#include <asm/asm-extable.h>
#include <asm/barrier.h>
#include <asm/errno.h>
......@@ -22,10 +23,8 @@
"4: li.w %0, %6 \n" \
" b 3b \n" \
" .previous \n" \
" .section __ex_table,\"a\" \n" \
" "__UA_ADDR "\t1b, 4b \n" \
" "__UA_ADDR "\t2b, 4b \n" \
" .previous \n" \
_ASM_EXTABLE(1b, 4b) \
_ASM_EXTABLE(2b, 4b) \
: "=r" (ret), "=&r" (oldval), \
"=ZC" (*uaddr) \
: "0" (0), "ZC" (*uaddr), "Jr" (oparg), \
......@@ -92,10 +91,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 oldval, u32 newv
"4: li.d %0, %6 \n"
" b 3b \n"
" .previous \n"
" .section __ex_table,\"a\" \n"
" "__UA_ADDR "\t1b, 4b \n"
" "__UA_ADDR "\t2b, 4b \n"
" .previous \n"
_ASM_EXTABLE(1b, 4b)
_ASM_EXTABLE(2b, 4b)
: "+r" (ret), "=&r" (val), "=ZC" (*uaddr)
: "ZC" (*uaddr), "Jr" (oldval), "Jr" (newval),
"i" (-EFAULT)
......
......@@ -15,6 +15,7 @@
#include <linux/string.h>
#include <linux/extable.h>
#include <asm/pgtable.h>
#include <asm/asm-extable.h>
#include <asm-generic/extable.h>
extern u64 __ua_limit;
......@@ -207,9 +208,7 @@ do { \
" move %1, $zero \n" \
" b 2b \n" \
" .previous \n" \
" .section __ex_table,\"a\" \n" \
" "__UA_ADDR "\t1b, 3b \n" \
" .previous \n" \
_ASM_EXTABLE(1b, 3b) \
: "+r" (__gu_err), "=r" (__gu_tmp) \
: "m" (__m(ptr)), "i" (-EFAULT)); \
\
......@@ -238,9 +237,7 @@ do { \
"3: li.w %0, %3 \n" \
" b 2b \n" \
" .previous \n" \
" .section __ex_table,\"a\" \n" \
" " __UA_ADDR " 1b, 3b \n" \
" .previous \n" \
_ASM_EXTABLE(1b, 3b) \
: "+r" (__pu_err), "=m" (__m(ptr)) \
: "Jr" (__pu_val), "i" (-EFAULT)); \
}
......
......@@ -8,6 +8,7 @@
*/
#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/asm-extable.h>
#include <asm/asm-offsets.h>
#include <asm/errno.h>
#include <asm/export.h>
......@@ -21,9 +22,7 @@
.macro EX insn, reg, src, offs
.ex\@: \insn \reg, \src, \offs
.section __ex_table,"a"
PTR .ex\@, fault
.previous
_asm_extable .ex\@, fault
.endm
.macro EX_V insn, reg, src, offs
......@@ -34,9 +33,7 @@
.ex\@:
.word __insn << 22 | __offs << 10 | __src << 5 | __reg
.section __ex_table,"a"
PTR .ex\@, fault
.previous
_asm_extable .ex\@, fault
.endm
.macro EX_XV insn, reg, src, offs
......@@ -47,9 +44,7 @@
.ex\@:
.word __insn << 22 | __offs << 10 | __src << 5 | __reg
.section __ex_table,"a"
PTR .ex\@, fault
.previous
_asm_extable .ex\@, fault
.endm
.macro sc_save_fp base
......
......@@ -5,6 +5,7 @@
#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/asm-extable.h>
#include <asm/export.h>
#include <asm/regdef.h>
......@@ -15,9 +16,7 @@
jr ra
.previous
.endif
.section __ex_table, "a"
PTR \from\()b, \to\()b
.previous
_asm_extable \from\()b, \to\()b
.endm
/*
......
......@@ -5,6 +5,7 @@
#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/asm-extable.h>
#include <asm/export.h>
#include <asm/regdef.h>
......@@ -15,9 +16,7 @@
jr ra
.previous
.endif
.section __ex_table, "a"
PTR \from\()b, \to\()b
.previous
_asm_extable \from\()b, \to\()b
.endm
/*
......
......@@ -7,6 +7,7 @@
#include <asm/asmmacro.h>
#include <asm/export.h>
#include <asm/regdef.h>
#include <asm/asm-extable.h>
/*
* long __strncpy_from_user(char *to, const char *from, long len)
......@@ -39,10 +40,7 @@ SYM_FUNC_START(__strncpy_from_user)
3: li.w a0, -EFAULT
jr ra
.previous
.section __ex_table, "a"
PTR 1b, 3b
.previous
_asm_extable 1b, 3b
SYM_FUNC_END(__strncpy_from_user)
EXPORT_SYMBOL(__strncpy_from_user)
......@@ -6,6 +6,7 @@
#include <asm/asmmacro.h>
#include <asm/export.h>
#include <asm/regdef.h>
#include <asm/asm-extable.h>
/*
* long __strnlen_user(const char *s, long n)
......@@ -36,9 +37,7 @@ SYM_FUNC_START(__strnlen_user)
jr ra
.previous
.section __ex_table, "a"
PTR 1b, 3b
.previous
_asm_extable 1b, 3b
SYM_FUNC_END(__strnlen_user)
EXPORT_SYMBOL(__strnlen_user)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册