From nobody Fri Feb 13 09:50:55 2026 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 192923BBCE for ; Mon, 15 Apr 2024 06:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713164084; cv=none; b=MJSzh/WoddbsJt7gAwgr7xTxcz9eOacwVtCtvEAz/IwvrnFOx/LGTmRjrqMi1DN4aj9WEAIU+zn32yGNzJRrgjjuqdBAqR9f21HXLUkNCTFYLRvHW4F2wo48TxcdYC+jSy5JwktG22nLX4iwZdG8Nb4rlAjGXAnwcbAWWbidOUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713164084; c=relaxed/simple; bh=L8BIW94zJz6w7DHCRiCf2wXwkrC31h4lsroI1eHffbU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nO77gvxr4mgwXlDygOULOEFLA+SYvdiJERiFMpqnlqZCOJOaxA2MJExzOhoe1P5i6ScbqaqcODM1+4tGY+MumkfKtKTnzen6A+Pwaj659bODKWrh+tT+kjXS4MfbzMBTZl1efQjZ/0BjimgbS/8D4GoI9UPhGjGWaMU/HsvsFzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VHyYv5H45zYdgf; Mon, 15 Apr 2024 14:53:39 +0800 (CST) Received: from kwepemd200013.china.huawei.com (unknown [7.221.188.133]) by mail.maildlp.com (Postfix) with ESMTPS id 1C60F1400CD; Mon, 15 Apr 2024 14:54:40 +0800 (CST) Received: from huawei.com (10.67.174.28) by kwepemd200013.china.huawei.com (7.221.188.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 15 Apr 2024 14:54:28 +0800 From: Liao Chang To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH v3 8/8] arm64: kprobe: Keep NMI maskabled while kprobe is stepping xol Date: Mon, 15 Apr 2024 06:47:58 +0000 Message-ID: <20240415064758.3250209-9-liaochang1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240415064758.3250209-1-liaochang1@huawei.com> References: <20240415064758.3250209-1-liaochang1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd200013.china.huawei.com (7.221.188.133) Content-Type: text/plain; charset="utf-8" Keeping NMI maskable while executing instruction out of line, otherwise, add kprobe on the functions invoken while handling NMI will cause kprobe reenter bug and kernel panic. Signed-off-by: Liao Chang --- arch/arm64/include/asm/daifflags.h | 2 ++ arch/arm64/kernel/probes/kprobes.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/da= ifflags.h index 1196eb85aa8d..60fd3b25fd73 100644 --- a/arch/arm64/include/asm/daifflags.h +++ b/arch/arm64/include/asm/daifflags.h @@ -17,6 +17,8 @@ #define DAIF_PROCCTX_NOIRQ (PSR_I_BIT | PSR_F_BIT) #define DAIF_ERRCTX (PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) #define DAIF_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) +#define DAIF_ALLINT_MASK \ + (system_uses_nmi() ? (ALLINT_ALLINT | DAIF_MASK) : (DAIF_MASK)) =20 /* * For Arm64 processor support Armv8.8 or later, kernel supports three typ= es diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/= kprobes.c index 327855a11df2..e8c2b993bbb8 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -187,13 +187,13 @@ static void __kprobes kprobes_save_local_irqflag(stru= ct kprobe_ctlblk *kcb, struct pt_regs *regs) { kcb->saved_irqflag =3D regs->pstate & DAIF_MASK; - regs->pstate |=3D DAIF_MASK; + regs->pstate |=3D DAIF_ALLINT_MASK; } =20 static void __kprobes kprobes_restore_local_irqflag(struct kprobe_ctlblk *= kcb, struct pt_regs *regs) { - regs->pstate &=3D ~DAIF_MASK; + regs->pstate &=3D ~DAIF_ALLINT_MASK; regs->pstate |=3D kcb->saved_irqflag; } =20 --=20 2.34.1