Commit 9fb43955 authored by Ma Wupeng's avatar Ma Wupeng Committed by Wupeng Ma
Browse files

arm64: send sig fault for user task when apei_claim_sea fails

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



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

During arm64_do_kernel_sea, kernel will panic if no info is reported to
kernel since apei_claim_sea will fail. However, for user task, sig fault
can be send to which can avoid kernel panic.

Signed-off-by: default avatarMa Wupeng <mawupeng1@huawei.com>
parent 9bb3fd60
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -729,6 +729,9 @@ static int do_bad(unsigned long addr, unsigned int esr, struct pt_regs *regs)
static bool arm64_do_kernel_sea(void __user *addr, unsigned int esr,
				struct pt_regs *regs, int sig, int code)
{
	u64 orig_pc = regs->pc;
	int err;

	if (!IS_ENABLED(CONFIG_ARCH_HAS_COPY_MC))
		return false;

@@ -738,14 +741,18 @@ static bool arm64_do_kernel_sea(void __user *addr, unsigned int esr,
	if (user_mode(regs))
		return false;

	if (apei_claim_sea(regs) < 0)
		return false;

	if (!fixup_exception_mc(regs))
		return false;

	if (current->flags & PF_KTHREAD)
		return true;
	err = apei_claim_sea(regs);
	if (err) {
		regs->pc = orig_pc;
		pr_emerg("apei claim sea failed. addr: %#lx, esr: %#x\n",
			 (unsigned long)addr, esr);
	}

	if (!current->mm)
		return err ? false : true;

	set_thread_esr(0, esr);
	arm64_force_sig_fault(sig, code, addr,