2019-05-23 11:14:57 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-07-10 18:03:49 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
|
|
|
|
* Lennox Wu <lennox.wu@sunplusct.com>
|
|
|
|
* Chen Liqin <liqin.chen@sunplusct.com>
|
|
|
|
* Copyright (C) 2013 Regents of the University of California
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/extable.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/uaccess.h>
|
2021-11-18 19:26:05 +08:00
|
|
|
#include <asm/asm-extable.h>
|
|
|
|
|
|
|
|
static inline unsigned long
|
|
|
|
get_ex_fixup(const struct exception_table_entry *ex)
|
|
|
|
{
|
|
|
|
return ((unsigned long)&ex->fixup + ex->fixup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ex_handler_fixup(const struct exception_table_entry *ex,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
regs->epc = get_ex_fixup(ex);
|
|
|
|
return true;
|
|
|
|
}
|
2017-07-10 18:03:49 -07:00
|
|
|
|
2021-11-18 19:24:14 +08:00
|
|
|
bool fixup_exception(struct pt_regs *regs)
|
2017-07-10 18:03:49 -07:00
|
|
|
{
|
2021-11-18 19:24:42 +08:00
|
|
|
const struct exception_table_entry *ex;
|
2017-07-10 18:03:49 -07:00
|
|
|
|
2021-11-18 19:24:42 +08:00
|
|
|
ex = search_exception_tables(regs->epc);
|
|
|
|
if (!ex)
|
2021-11-18 19:24:14 +08:00
|
|
|
return false;
|
2021-10-27 11:18:22 +00:00
|
|
|
|
2021-11-18 19:26:05 +08:00
|
|
|
switch (ex->type) {
|
|
|
|
case EX_TYPE_FIXUP:
|
|
|
|
return ex_handler_fixup(ex, regs);
|
|
|
|
case EX_TYPE_BPF:
|
|
|
|
return ex_handler_bpf(ex, regs);
|
|
|
|
}
|
2021-10-27 11:18:22 +00:00
|
|
|
|
2021-11-18 19:26:05 +08:00
|
|
|
BUG();
|
2017-07-10 18:03:49 -07:00
|
|
|
}
|