From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.136.65.225 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795385935; b=1cMkkObDVJV+fDQNAcE/yTtqBHVaQNIM4nirjFM5e8KL71WSok6JvYijmOXnMOPKIWmn 4zW7sTNl/zPI8Pb4yFhf79wQyObD899C5qdrEfUnYLzVbxTUhl+47rg4OOw09bOIjBQQH +zy5LjhmIcBCKKXdCQDGEY1sqsxXB3yLStMTSB6DsZswr5i3l0eGo0Rd0rHcqSCpKrpd4 zEs7aHJGaAQxA9yj2GlGyAYTemOQBhEmWHZ/xwwRM3WicanlLPxFcg05pkUfTQ3vPVWyE EPzFgoqKpl9H45Wv8wYxLP3KjiVLLquxuqPyWg7qL9mZiYZI4IsRuOnjSvfZwYhTlqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795385935; h=DMARC-Filter:Received:DKIM-Signature:Mime-Version: Content-Transfer-Encoding:Content-Type:Date:Message-Id:Cc:Subject: From:To:References:In-Reply-To:X-Flowmailer-Platform:Feedback-ID; bh=BZODCDBcx3a+28ILYn0BtaEP8iyY8goBXB3SKC5on6s=; b=2s3pFjiQHcJebvT0ZnRaOMy5Blfox+whH5ayXUWgMDOzwwo9qMCisi9vHX3/gpJ+++LB 69dUcTaPBOzGSvLD+rUhxfM60/GE9faRNlo0iYMbyDDCje9Z36Z2YzrlIlgCSvDa9vl6d I94k66ZOAJohxE6wWLpYQnoNJ7zI6GW3XQd6Ud2XDPirhJyHopAxDnN0Nz26YzQRAKkC8 oF+y9n3LLc12kuB3JkPel7XGqjJNZpe+mbCdh45mkX7DOh1v5vs6xMuDI4C/+XrQOrwSq F3yVQDjg4AIgu2OHWCm2UH7SH3uFynda9T3EgsEG628shP2jtXvC9cpRZAKHsf+Atmg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=siemens.com; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com; dkim=pass header.d=siemens.com header.i=florian.bezdeka@siemens.com header.a=rsa-sha256 header.s=fm1 header.b=puV99m09; arc=none smtp.remote-ip=185.136.65.225 Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE3B9606A31D for ; Sun, 22 Nov 2026 22:18:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AE3B9606A31D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=siemens.com header.i=florian.bezdeka@siemens.com header.a=rsa-sha256 header.s=fm1 header.b=puV99m09 Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 2026112222185063ca90ab3a0002071b for ; Sun, 22 Nov 2026 23:18:50 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=florian.bezdeka@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=BZODCDBcx3a+28ILYn0BtaEP8iyY8goBXB3SKC5on6s=; b=puV99m09Ep8puVbjvfQRDxVczA6BBs6mbVXawwbcidj08K6wgSZhf9MiMH0Adw76lx+NqF jFH3NOLthgbaGnYgNO3+yO6Ghr+P7n9+qMuVk7nnhZpXccp+7bjguUgzsfbq2KG+4giCNHxD Ydkw3Yml9lPMu8yhomfL4vfjaGoUPUvX1SRe1WNgUVH+7eGjE8/5Ihs63n7njLa3fA+rSq/o CeRvGfWgOIS9OnFUTnhwDy8KlWI6+8eG995ANoTU/qIBmgtg/8Ks1Ko2JAGSf+fMI5DfZZ0N OAhNm/I6MfAWS9CMDRpkQZmUmmAT2EDk0O0Djws36Apanmk4ER4QhStg==; X-Mailing-List: xenomai@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 22 Nov 2026 23:18:49 +0100 Message-Id: Cc: , Subject: Re: [PATCH dovetail v2 3/4] riscv: dovetail: inherit the hard irq state on kernel page faults From: Florian Bezdeka To: "Tobias Schaffner" , References: <20261121165933.57310-1-tobias.schaffner@siemens.com> <20261121165933.57310-4-tobias.schaffner@siemens.com> In-Reply-To: <20261121165933.57310-4-tobias.schaffner@siemens.com> X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-68982:519-21489:flowmailer On Sat Nov 21, 2026 at 5:59 PM CET, Tobias Schaffner wrote: > A page fault may hit kernel code which runs with hard irqs off, e.g. a > kprobe whose fetch argument faults within the breakpoint trap. The fault > handler still enables hard irqs for every kernel mode fault, so an > interrupt may break into that code. If the fault is handled out-of-band, > the handler also unstalls the in-band stage over the out-of-band stage. > > Enable hard irqs in handle_page_fault() only if the faulting code had > them on and we run in-band, and stall the in-band stage on exit only if > we run in-band. > > Fixes: 1d1fdeccecef ("riscv: dovetail: add core support") > Signed-off-by: Tobias Schaffner > --- > arch/riscv/kernel/traps.c | 11 ++++------- > arch/riscv/mm/fault.c | 7 +++++-- > 2 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c > index a8e37ec27cc2..47799f18fa7d 100644 > --- a/arch/riscv/kernel/traps.c > +++ b/arch/riscv/kernel/traps.c > @@ -488,17 +488,14 @@ asmlinkage __visible __trap_section void do_trap_so= ftware_check(struct pt_regs * > asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs) > { > irqentry_state_t state =3D irqentry_enter(regs); > + bool inband =3D mark_trap_entry(regs); > =20 > - mark_trap_entry(regs); > - > - BUG_ON(dovetail_debug() && !running_inband()); > - > - if (!user_mode(regs)) > - hard_cond_local_irq_enable(); > + BUG_ON(dovetail_debug() && !inband && user_mode(regs)); > =20 > handle_page_fault(regs, state); > =20 > - local_irq_disable(); > + if (inband) > + local_irq_disable(); > =20 > mark_trap_exit(regs); > =20 > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c > index c5709112c346..f72b49d8f15a 100644 > --- a/arch/riscv/mm/fault.c > +++ b/arch/riscv/mm/fault.c > @@ -317,8 +317,11 @@ void handle_page_fault(struct pt_regs *regs, irqentr= y_state_t state) > =20 > /* Enable interrupts if they were enabled in the parent context. */ > #ifdef CONFIG_IRQ_PIPELINE > - if (state.stage_info !=3D IRQENTRY_INBAND_STALLED) > - local_irq_enable_full(); > + if (running_inband() && !regs_irqs_disabled(regs)) { > + hard_local_irq_enable(); > + if (state.stage_info !=3D IRQENTRY_INBAND_STALLED) > + local_irq_enable(); > + } Is that part aligned with any of the other architectures? I'm asking because it seems that the pattern used here has an ordering problem. Once we enabled hard IRQs with hard_local_irq_enable() hardware events might come in, hitting an stalled inband stage. Means we log all the events into the IRQ log. When we unstall the inband stage with local_irq_enable(), that will bring us a full IRQ log synchronization - over page fault handling. As local_irq_enable_full() does it the other way around as well, I think that the ordering is wrong. If taken / aligned from/with an other arch: we should check that as well. > #else > if (!regs_irqs_disabled(regs)) > local_irq_enable();