Commit bab26fe2 authored by Tong Tiangen's avatar Tong Tiangen Committed by Ma Wupeng
Browse files

arm64: extable: add new extable type "__mc_ex_table"

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5GB28


CVE: NA

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

A new type of extable is added, which is specially used fixup for machine
check safe.
In order to keep kabi consistency, we cannot add type and data members to
struct exception_table_entry(d6e2cc56 arm64: extable: add `type` and
`data` fields), so we put the fixup entry to new extable separately.

Signed-off-by: default avatarTong Tiangen <tongtiangen@huawei.com>
parent 406637c1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1171,6 +1171,9 @@ config ARCH_LLC_128_LINE_SIZE
config ARCH_HAS_FILTER_PGPROT
	def_bool y

config ARCH_HAS_MC_EXTABLE
	bool

config ARCH_ENABLE_SPLIT_PMD_PTLOCK
	def_bool y if PGTABLE_LEVELS > 2

+15 −0
Original line number Diff line number Diff line
@@ -145,6 +145,21 @@ alternative_endif
	.popsection
	.endm

/*
 * Emit an entry into the machine check exception table
 */
#ifdef CONFIG_ARCH_HAS_MC_EXTABLE
	.macro		_asm_mc_extable, from, to
	.pushsection	__mc_ex_table, "a"
	.align		3
	.long		(\from - .), (\to - .)
	.popsection
	.endm
#else
	.macro		_asm_mc_extable, from, to
	.endm
#endif

#define USER(l, x...)				\
9999:	x;					\
	_asm_extable	9999b, l
+10 −0
Original line number Diff line number Diff line
@@ -75,6 +75,16 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si
	"	.long		(" #from " - .), (" #to " - .)\n"	\
	"	.popsection\n"

#ifdef CONFIG_ARCH_HAS_MC_EXTABLE
#define _ASM_MC_EXTABLE(from, to)					\
	"	.pushsection	__mc_ex_table, \"a\"\n"			\
	"	.align		3\n"					\
	"	.long		(" #from " - .), (" #to " - .)\n"	\
	"	.popsection\n"
#else
#define _ASM_MC_EXTABLE(from, to)
#endif

/*
 * User access enabling/disabling.
 */
+18 −1
Original line number Diff line number Diff line
@@ -76,7 +76,9 @@
 * alignment.
 */
#ifdef RO_EXCEPTION_TABLE_ALIGN
#define RO_EXCEPTION_TABLE	EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN)
#define RO_EXCEPTION_TABLE					\
	EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN)		\
	MC_EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN)
#else
#define RO_EXCEPTION_TABLE
#endif
@@ -675,6 +677,21 @@
		__stop___ex_table = .;					\
	}

#ifdef CONFIG_ARCH_HAS_MC_EXTABLE
/*
 * Machine Check Exception table
 */
#define MC_EXCEPTION_TABLE(align)					\
	. = ALIGN(align);						\
	__mc_ex_table : AT(ADDR(__mc_ex_table) - LOAD_OFFSET) {		\
		__start___mc_ex_table = .;				\
		KEEP(*(__mc_ex_table))					\
		__stop___mc_ex_table = .;				\
	}
#else
#define MC_EXCEPTION_TABLE(align)
#endif

/*
 * .BTF
 */
+23 −0
Original line number Diff line number Diff line
@@ -19,18 +19,41 @@ void trim_init_extable(struct module *m);

/* Given an address, look for it in the exception tables */
const struct exception_table_entry *search_exception_tables(unsigned long add);
#ifdef CONFIG_ARCH_HAS_MC_EXTABLE
const struct exception_table_entry *search_mc_exception_tables(unsigned long add);
#else
static inline const struct exception_table_entry *
search_mc_exception_tables(unsigned long add)
{
	return NULL;
}
#endif
const struct exception_table_entry *
search_kernel_exception_table(unsigned long addr);

#ifdef CONFIG_MODULES
/* For extable.c to search modules' exception tables. */
const struct exception_table_entry *search_module_extables(unsigned long addr);
#ifdef CONFIG_ARCH_HAS_MC_EXTABLE
const struct exception_table_entry *search_module_mc_extables(unsigned long addr);
#else
static inline const struct exception_table_entry *
search_module_mc_extables(unsigned long addr)
{
	return NULL;
}
#endif
#else
static inline const struct exception_table_entry *
search_module_extables(unsigned long addr)
{
	return NULL;
}
static inline const struct exception_table_entry *
search_module_mc_extables(unsigned long addr)
{
	return NULL;
}
#endif /*CONFIG_MODULES*/

#ifdef CONFIG_BPF_JIT
Loading