From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (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 74940501F49; Wed, 16 Sep 2026 14:07:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789567635; cv=none; b=PKGFIO3GtCDvGFvePalQPk9TWO/4opv5ZKGMfBNTWRJj6kWWKO1TA8XcdIWIhUJV0xiX0PmjxcRnpfLd0MAhHXE4a8HF2nHKTpMMJOM6ohLqq0jJ1HwYo311mEpCkOJmAqrR0xBpBCpa7qOqBLRlIyYoZaGDoty8f9o1nRJTIBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789567635; c=relaxed/simple; bh=MGV0/UiveNiiGplXBn4NQhOcOJpFAI97dT32wObLO5Y=; h=Date:Message-Id:To:Cc:Subject:From:In-Reply-To:References: Mime-Version:Content-Type; b=Fa5LlZNNkRTxB9nGqvVAQyAVcD/eTibNkkHusZCFhEbU3feh+Bdreq+nW2ToKi/1brwyjBrd0BAtkbYUrzrsFfiHB4ihC8nA/iTWARJvCAi2nbg0FJ1QJS9lJt903hNgW6CAYrQASj06bVUyZhdVv1WMscxxcaMej+NGs5nLiZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org; spf=pass smtp.mailfrom=flapping.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b=deAxxL2q; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=usEP3hhL; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flapping.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b="deAxxL2q"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="usEP3hhL" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 7F760EC00D8; Wed, 16 Sep 2026 10:07:12 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Wed, 16 Sep 2026 10:07:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flapping.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1789567632; x=1789654032; bh=Be2o5M1d9xljHYCRtuNcdhNIc/2it5l8BznRP32aB+E=; b= deAxxL2qOz3i3Nk280cG2SuqAGf0LERKkb+BKPxddkO2Uggd14mT0texUPBovaEQ U9mx9skBudy7DVI5XFPEjTyPgiSnnY3sR3Dgvrv+O/16UiOhJpQbUmhbPwfxvaiO Oo8i04bkxS0tZmGyjWNJu9Bcwo70WPSy1ft7ZIUoYMH8uk0L4LoPSdTu0aoGe2vT Lf7CpUcdN1ceH8IqpBf9efrfO4dIN+Diz+X/7yX+ZNEJ/VFyZvUMjzyE7HZ+atjS fGxoGE8k3Xdz6d0H9qxYVFk67YMdFy0QFZAFT9hpWLyg2iURMGbHhvG2swWodIrW gSeGT8jxhQmJo+m5IjNkkA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1789567632; x= 1789654032; bh=Be2o5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XsFiTYl3RjyJ0E7U7O4Irjvs+6S4HOLmJSspbWI3vg X-ME-Proxy: Feedback-ID: i51fe4b43:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 16 Sep 2026 10:07:02 -0400 (EDT) Date: Wed, 16 Sep 2026 23:06:58 +0900 (JST) Message-Id: <20260916.230658.2266384286281034372.tomo@flapping.org> To: mkchauras@gmail.com Cc: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, dakr@kernel.org, daniel.almeida@collabora.com, tamird@kernel.org, acourbot@nvidia.com, work@onurozkan.dev, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, ynorov@nvidia.com, david@davidgow.net, joelagnelf@nvidia.com, fujita.tomonori@gmail.com, linkmauve@linkmauve.fr, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev Subject: Re: [PATCH V5 2/2] rust: kernel: Add KUnit tests for powerpc ARCH_WARN_ASM bug table emission From: FUJITA Tomonori In-Reply-To: <20260915090453.1227034-3-mkchauras@gmail.com> References: <20260915090453.1227034-1-mkchauras@gmail.com> <20260915090453.1227034-3-mkchauras@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit On Tue, 15 Sep 2026 14:34:53 +0530 "Mukesh Kumar Chaurasiya (IBM)" wrote: > Verify that the __bug_table entry emitted by ARCH_WARN_ASM has a correct > bug_addr displacement ― i.e. the '1b' label reference in _EMIT_BUG_ENTRY > resolves to the trap instruction ― by calling find_bug() with the exact > virtual address of the twi instruction, mirroring what the real powerpc > trap handler does. > > The trap address is captured at link time via a .dc.a 1b relocation placed > in .data by the global_asm! block. global_asm! is used instead of asm! > because LLVM eliminates asm! blocks in dead branches; global_asm! is > file-scope and always emitted. BUG_KUNIT_TRAP_ADDR is defined as a .global > symbol directly on the .dc.a word so the linker relocation lands on it ― > a Rust static initialized to zero would end up in BSS where relocations are > not applied. > > .dc.a emits a pointer-width word (4 bytes on ppc32, 8 bytes on ppc64), > so BUG_KUNIT_TRAP_ADDR is declared as usize on the Rust side, making the > tests correct on both ppc32 and ppc64. The global_asm! block is split into > two cfg-gated variants (CONFIG_PPC64 / !CONFIG_PPC64) to select the right > .balign since concat!() only accepts literals. > > Five tests are included in the rust_kernel_bug_powerpc suite: > > bug_entry_found - find_bug() returns non-NULL for the trap address, > proving the bug_addr displacement is correct > bug_entry_is_warning - the emitted entry has BUGFLAG_WARNING set > bug_entry_file - bug_get_file_line() returns the correct source > file (requires CONFIG_DEBUG_BUGVERBOSE) > bug_entry_line - the recorded line number is non-zero, confirming > the {line} operand was substituted correctly > (requires CONFIG_DEBUG_BUGVERBOSE) > bug_entry_addr_is_in_text - kernel_text_address() confirms the trap address > lies in kernel text, not data or zero > > The suite is named rust_kernel_bug_powerpc and the Kconfig option > CONFIG_RUST_BUG_POWERPC_KUNIT_TEST depends on PPC && GENERIC_BUG, > covering both ppc32 and ppc64. > > Tested on ppc64le (ltcfujiaac-lp3, 7.3.0-rc1+): pass:5 fail:0 skip:0. > Tested on ppc32 Book3S (QEMU mac99 G4, chrp32_defconfig): pass:5 fail:0 skip:0. > Tested on ppc64le (QEMU pseries, pseries_le_defconfig): pass:5 fail:0 skip:0. > > Signed-off-by: Mukesh Kumar Chaurasiya (IBM) > --- > rust/kernel/Kconfig.test | 13 +++ > rust/kernel/bug.rs | 209 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 222 insertions(+) I think that testing warn_on!, in particular that the right address is put in the bug entry, is a good idea. I'd prefer such a test to work on every architecture. This one depends on details of powerpc's ARCH_WARN_ASM, such as the '1b' label. KUnit has a warning suppression API. A test can call warn_on! inside a suppression block and check that one warning was counted. The counter is only incremented after find_bug() found the entry, so a wrong address is caught too. I'll send a patch for that shortly.