[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240614034433.602622-9-liaochang1@huawei.com>
Date: Fri, 14 Jun 2024 03:44:31 +0000
From: Liao Chang <liaochang1@...wei.com>
To: <catalin.marinas@....com>, <will@...nel.org>, <ryabinin.a.a@...il.com>,
<glider@...gle.com>, <andreyknvl@...il.com>, <dvyukov@...gle.com>,
<vincenzo.frascino@....com>, <maz@...nel.org>, <oliver.upton@...ux.dev>,
<james.morse@....com>, <suzuki.poulose@....com>, <yuzenghui@...wei.com>,
<mark.rutland@....com>, <lpieralisi@...nel.org>, <tglx@...utronix.de>,
<ardb@...nel.org>, <broonie@...nel.org>, <liaochang1@...wei.com>,
<steven.price@....com>, <ryan.roberts@....com>, <pcc@...gle.com>,
<anshuman.khandual@....com>, <eric.auger@...hat.com>,
<miguel.luis@...cle.com>, <shiqiliu@...t.edu.cn>, <quic_jiles@...cinc.com>,
<rafael@...nel.org>, <sudeep.holla@....com>, <dwmw@...zon.co.uk>,
<joey.gouly@....com>, <jeremy.linton@....com>, <robh@...nel.org>,
<scott@...amperecomputing.com>, <songshuaishuai@...ylab.org>,
<swboyd@...omium.org>, <dianders@...omium.org>,
<shijie@...amperecomputing.com>, <bhe@...hat.com>,
<akpm@...ux-foundation.org>, <rppt@...nel.org>, <mhiramat@...nel.org>,
<mcgrof@...nel.org>, <rmk+kernel@...linux.org.uk>,
<Jonathan.Cameron@...wei.com>, <takakura@...inux.co.jp>,
<sumit.garg@...aro.org>, <frederic@...nel.org>, <tabba@...gle.com>,
<kristina.martsenko@....com>, <ruanjinjie@...wei.com>
CC: <linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<kasan-dev@...glegroups.com>, <kvmarm@...ts.linux.dev>
Subject: [PATCH v4 08/10] arm64: kprobe: Keep NMI maskabled while kprobe is stepping xol
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 <liaochang1@...wei.com>
---
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/daifflags.h
index 4eb97241a58f..01c7123d5604 100644
--- a/arch/arm64/include/asm/daifflags.h
+++ b/arch/arm64/include/asm/daifflags.h
@@ -16,6 +16,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))
/*
* For Arm64 processor support Armv8.8 or later, kernel supports three types
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 4268678d0e86..efcf6d478dbc 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -180,13 +180,13 @@ static void __kprobes kprobes_save_local_irqflag(struct kprobe_ctlblk *kcb,
struct pt_regs *regs)
{
kcb->saved_irqflag = regs->pstate & DAIF_MASK;
- regs->pstate |= DAIF_MASK;
+ regs->pstate |= DAIF_ALLINT_MASK;
}
static void __kprobes kprobes_restore_local_irqflag(struct kprobe_ctlblk *kcb,
struct pt_regs *regs)
{
- regs->pstate &= ~DAIF_MASK;
+ regs->pstate &= ~DAIF_ALLINT_MASK;
regs->pstate |= kcb->saved_irqflag;
}
--
2.34.1
Powered by blists - more mailing lists