From: Gabriele Paoloni <gpaoloni@redhat.com>
To: corbet@lwn.net, skhan@linuxfoundation.org, arnd@arndb.de,
gregkh@linuxfoundation.org, brendan.higgins@linux.dev,
raemoar63@gmail.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
kunit-dev@googlegroups.com
Cc: acarminati@nvidia.com, linux-mm@kvack.org,
safety-architecture@lists.elisa.tech,
kstewart@linuxfoundation.org, chuckwolber@gmail.com,
gpaoloni@redhat.com, Alessandro Carminati <acarmina@redhat.com>
Subject: [RFC PATCH v3 6/6] char: mem: add Kconfig option for devmem KUnit tests
Date: Thu, 12 Feb 2026 13:49:23 +0100 [thread overview]
Message-ID: <20260212124923.222484-7-gpaoloni@redhat.com> (raw)
In-Reply-To: <20260212124923.222484-1-gpaoloni@redhat.com>
From: Alessandro Carminati <acarmina@redhat.com>
Introduce a dedicated Kconfig option to enable extended KUnit testing
for /dev/mem behavior.
The option enables tests covering I/O memory access restrictions,
including behavior under CONFIG_IO_STRICT_DEVMEM. Because the tests may
perform reads from I/O regions, they are opt-in and documented with
appropriate warnings.
This keeps test coverage explicit and avoids unintended hardware
side effects.
Signed-off-by: Alessandro Carminati <acarmina@redhat.com>
---
drivers/char/Kconfig | 21 +++++++++++++++++++++
drivers/char/Makefile | 1 +
2 files changed, 22 insertions(+)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index d2cfc584e202..cd3e47b47f44 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -317,6 +317,27 @@ config DEVMEM
memory.
When in doubt, say "Y".
+config DEVMEM_KUNIT_TEST
+ tristate "KUnit tests for /dev/mem" if !KUNIT_ALL_TESTS
+ depends on KUNIT
+ default KUNIT_ALL_TESTS
+ help
+ Enables in-kernel unit tests for /dev/mem read/write logic.
+
+config DEVMEM_KUNIT_TEST_IO
+ bool "KUnit tests for /dev/mem extended to I/O space"
+ depends on DEVMEM_KUNIT_TEST
+ default n
+ help
+ Extend KUnit tests for devmem to cover IO space.
+ When CONFIG_IO_STRICT_DEVMEM is enabled, the kernel denies
+ access to claimed IO regions. Enabling this option adds two
+ KUnit test cases to verify this behavior.
+ Note: These tests perform read operations, which can have
+ side effects on certain hardware.
+ Enable this only if you are certain your hardware handles
+ unsolicited reads safely.
+
config NVRAM
tristate "/dev/nvram support"
depends on X86 || HAVE_ARCH_NVRAM_OPS
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 1291369b9126..176f2b8f98dc 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -4,6 +4,7 @@
#
obj-y += mem.o random.o
+obj-$(CONFIG_DEVMEM_KUNIT_TEST) += mem_kunit_test.o
obj-$(CONFIG_TTY_PRINTK) += ttyprintk.o
obj-y += misc.o
obj-$(CONFIG_TEST_MISC_MINOR) += misc_minor_kunit.o
--
2.48.1
prev parent reply other threads:[~2026-02-12 12:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 12:49 [RFC PATCH v3 0/6] some /dev/mem specifications and traced testing Gabriele Paoloni
2026-02-12 12:49 ` [RFC PATCH v3 1/6] Documentation: extend the 'Function documentation' with expected behavior and constraints of use Gabriele Paoloni
2026-02-12 12:59 ` Greg KH
2026-02-12 14:00 ` Gabriele Paoloni
2026-02-12 15:23 ` Greg KH
2026-02-13 17:13 ` Gabriele Paoloni
2026-02-12 12:49 ` [RFC PATCH v3 2/6] /dev/mem: Add initial documentation of memory_open() and mem_fops Gabriele Paoloni
2026-02-12 12:49 ` [RFC PATCH v3 3/6] kunit: add visibility helpers for static inline functions Gabriele Paoloni
2026-02-12 12:49 ` [RFC PATCH v3 4/6] char: mem: expose devmem helpers for KUnit testing Gabriele Paoloni
2026-02-12 12:49 ` [RFC PATCH v3 5/6] char: mem: add KUnit tests for /dev/mem read_mem() Gabriele Paoloni
2026-02-12 12:49 ` Gabriele Paoloni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260212124923.222484-7-gpaoloni@redhat.com \
--to=gpaoloni@redhat.com \
--cc=acarmina@redhat.com \
--cc=acarminati@nvidia.com \
--cc=arnd@arndb.de \
--cc=brendan.higgins@linux.dev \
--cc=chuckwolber@gmail.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=kstewart@linuxfoundation.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=raemoar63@gmail.com \
--cc=safety-architecture@lists.elisa.tech \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox