From 0f44994850f3a52be9077222bb717321da422705 Mon Sep 17 00:00:00 2001 From: Wu Liliu Date: Thu, 23 Jun 2022 14:31:07 +0800 Subject: [PATCH] sw64: check processor state by user_mode(regs) Sunway inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I56OLG -------------------------------- The `regs->ps & 8` and `regs->ps & ~IPL_MAX` don't have a clear meaning. We replace them with user_mode(regs) and !user_mode(regs), and reserve regs->ps[63:4] for future extension. Signed-off-by: Wu Liliu Signed-off-by: Gu Zitao --- arch/sw_64/kernel/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/sw_64/kernel/traps.c b/arch/sw_64/kernel/traps.c index 4e95cab13daa..8c7fdeeef491 100644 --- a/arch/sw_64/kernel/traps.c +++ b/arch/sw_64/kernel/traps.c @@ -77,7 +77,7 @@ dik_show_code(unsigned int *pc) void die_if_kernel(char *str, struct pt_regs *regs, long err) { - if (regs->ps & 8) + if (user_mode(regs)) return; #ifdef CONFIG_SMP printk("CPU %d ", hard_smp_processor_id()); @@ -149,7 +149,7 @@ do_entIF(unsigned long inst_type, struct pt_regs *regs) type = inst_type & 0xffffffff; inst = inst_type >> 32; - if ((regs->ps & ~IPL_MAX) == 0 && type != 4) { + if (!user_mode(regs) && type != 4) { if (type == 1) { const unsigned int *data = (const unsigned int *) regs->pc; @@ -253,7 +253,7 @@ do_entIF(unsigned long inst_type, struct pt_regs *regs) if (notify_die(DIE_UPROBE_XOL, "uprobe_xol", regs, 0, 0, SIGTRAP) == NOTIFY_STOP) return; } - if ((regs->ps & ~IPL_MAX) == 0) + if (!user_mode(regs)) die_if_kernel("Instruction fault", regs, type); break; -- GitLab