From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Kees Cook <kees@kernel.org>,
Joel Granados <joel.granados@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
kernel-dev@igalia.com, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, fsverity@lists.linux.dev,
keyrings@vger.kernel.org, bpf@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org,
netdev@vger.kernel.org, linux-wpan@vger.kernel.org,
lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, linux-sctp@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
bridge@lists.linux.dev, mptcp@lists.linux.dev,
rds-devel@oss.oracle.com, virtualization@lists.linux.dev
Subject: Re: [PATCH RFC v3 03/13] sysctl, mod_devicetable: add macro MODULE_SYSCTL_TABLE
Date: Tue, 25 Aug 2026 16:10:17 -0300 [thread overview]
Message-ID: <4a7925a800f0c9b36078a70bf35e960d@igalia.com> (raw)
In-Reply-To: <ao1P_mEJdyRExG3v@monoceros>
On 2026-08-25 05:24, Uwe Kleine-König wrote:
> Hello,
>
> On Mon, Aug 24, 2026 at 06:04:03PM -0300, Mauricio Faria de Oliveira wrote:
>> On 2026-08-23 19:12, Uwe Kleine-König wrote:
>> > On Sat, Aug 22, 2026 at 01:57:24PM -0300, Mauricio Faria de Oliveira wrote:
>> >> On 2026-08-22 10:41, Uwe Kleine-König wrote:
>> >> > On Wed, Aug 19, 2026 at 03:16:16PM -0300, Mauricio Faria de Oliveira wrote:
>> >> >> The MODULE_SYSCTL_TABLE macro emits a struct module_sysctl_table variable
>> >> >> with pointers to a sysctl table's path and entries, and table/entry sizes.
>> >> >
>> >> > That new struct doesn't seem to contain any pointer?
>> >>
>> >> The struct module_sysctl_table fields .path and .table are pointers,
>> >> although with kernel_ulong_t type so that the same 32/64-bit size is
>> >> used in file2alias.c based on KERNEL_ELFCLASS (and not on the host,
>> >> which might differ with CROSS_COMPILE).
>> >
>> > Cross compilation isn't an issue for the already existing device id
>> > structures; many of them also contain pointers.
>> > (While modpost doesn't use the pointers, the size of the structures must
>> > be known to correctly interpret the arrays.)
>>
>> Indeed. I missed some device_id structures with pointers, and that
>> devicetable-offsets.c is cross-compiled to generate
>> devicetable-offsets.h for file2alias.c to use offsets and sizes of the
>> target architecture.
>>
>> I'll change .path and .table to pointers in the next version.
>
> I *think* the existing device-id structs use char[] for strings that are
> relevant for modpost. I look forward to you finding out if there is
> still a justification for that :-D
AFAICT, an array is simpler to read in file2alias as it is stored
directly in the symbol:
For example:
@ include/linux/device-id/of.h
struct of_device_id {
...
char compatible[128];
...
@ drivers/net/ethernet/korina.c
static const struct of_device_id korina_match[] = {
{
.compatible = "idt,3243x-emac",
...
MODULE_DEVICE_TABLE(of, korina_match);
which builds
$ objdump -t drivers/net/ethernet/korina.o | grep __mod_device_table
0000000000001020 l O .rodata 0000000000000190
__mod_device_table__kmod_korina__of__korina_match
$ objdump -s -j .rodata --start-address=0x1020
--stop-address=$((0x1020+0x190)) drivers/net/ethernet/korina.o
...
1020 00000000 00000000 00000000 00000000 ................
1030 00000000 00000000 00000000 00000000 ................
1040 00000000 00000000 00000000 00000000 ................
1050 00000000 00000000 00000000 00000000 ................
1060 6964742c 33323433 782d656d 61630000 idt,3243x-emac..
1070 00000000 00000000 00000000 00000000 ................
...
@ scripts/mod/file2lias.c
#define DEF_FIELD_ADDR(m, devid, f) \
typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f)
static void do_of_entry(struct module *mod, void *symval)
{
...
DEF_FIELD_ADDR(symval, of_device_id, compatible);
...
void handle_moddevtable(struct module *mod, struct elf_info *info,
Elf_Sym *sym, const char *symname)
{
void *symval;
...
symval = sym_get_data(info, sym);
On the other hand, a pointer is stored indirectly through a relocation
in the symbol, which is not as simple to read (i.e., 1. find the
relocation section for the symbol's section; 2. find the relocation in
that section by matching relocation offsets with an offset in the symbol
+ symbol address; 3. finally read the relocation's target).
>> > I would be great if your series didn't introduce a new obstacle for
>> > [CHERI].
>>
>> Absolutely. I'll be happy to adjust the series and testing for that.
>>
>> Could you please confirm one should just follow [1], which uses [2] to
>> build the LLVM toolchain, and use it to build the kernel [3]?
>>
>> [1] https://github.com/cheri-linux#building-and-running
>> [2] https://github.com/cheri-linux/buildroot
>> [3] https://github.com/CHERI-Alliance/linux/tree/codasip-cheri-riscv-7.1
>
> I used
> https://github.com/CHERI-Alliance/meta-cheri/tree/codasip-scarthgap and
> didn't care about toolchain and rootfs. It also has qemu integrated, so
> you can actually test it.
I'll take a look; thanks!
cheers,
>
> Best regards
> Uwe
--
Mauricio
WARNING: multiple messages have this Message-ID (diff)
From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Kees Cook <kees@kernel.org>,
Joel Granados <joel.granados@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
kernel-dev@igalia.com, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, fsverity@lists.linux.dev,
keyrings@vger.kernel.org, bpf@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org,
netdev@vger.kernel.org, linux-wpan@vger.kernel.org,
lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, linux-sctp@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
bridge@lists.linux.dev, mptcp@lists.linux.dev,
rds-devel@oss.oracle.com, virtualization@lists.linux.dev
Subject: Re: [PATCH RFC v3 03/13] sysctl, mod_devicetable: add macro MODULE_SYSCTL_TABLE
Date: Tue, 25 Aug 2026 16:10:17 -0300 [thread overview]
Message-ID: <4a7925a800f0c9b36078a70bf35e960d@igalia.com> (raw)
In-Reply-To: <ao1P_mEJdyRExG3v@monoceros>
On 2026-08-25 05:24, Uwe Kleine-König wrote:
> Hello,
>
> On Mon, Aug 24, 2026 at 06:04:03PM -0300, Mauricio Faria de Oliveira wrote:
>> On 2026-08-23 19:12, Uwe Kleine-König wrote:
>> > On Sat, Aug 22, 2026 at 01:57:24PM -0300, Mauricio Faria de Oliveira wrote:
>> >> On 2026-08-22 10:41, Uwe Kleine-König wrote:
>> >> > On Wed, Aug 19, 2026 at 03:16:16PM -0300, Mauricio Faria de Oliveira wrote:
>> >> >> The MODULE_SYSCTL_TABLE macro emits a struct module_sysctl_table variable
>> >> >> with pointers to a sysctl table's path and entries, and table/entry sizes.
>> >> >
>> >> > That new struct doesn't seem to contain any pointer?
>> >>
>> >> The struct module_sysctl_table fields .path and .table are pointers,
>> >> although with kernel_ulong_t type so that the same 32/64-bit size is
>> >> used in file2alias.c based on KERNEL_ELFCLASS (and not on the host,
>> >> which might differ with CROSS_COMPILE).
>> >
>> > Cross compilation isn't an issue for the already existing device id
>> > structures; many of them also contain pointers.
>> > (While modpost doesn't use the pointers, the size of the structures must
>> > be known to correctly interpret the arrays.)
>>
>> Indeed. I missed some device_id structures with pointers, and that
>> devicetable-offsets.c is cross-compiled to generate
>> devicetable-offsets.h for file2alias.c to use offsets and sizes of the
>> target architecture.
>>
>> I'll change .path and .table to pointers in the next version.
>
> I *think* the existing device-id structs use char[] for strings that are
> relevant for modpost. I look forward to you finding out if there is
> still a justification for that :-D
AFAICT, an array is simpler to read in file2alias as it is stored
directly in the symbol:
For example:
@ include/linux/device-id/of.h
struct of_device_id {
...
char compatible[128];
...
@ drivers/net/ethernet/korina.c
static const struct of_device_id korina_match[] = {
{
.compatible = "idt,3243x-emac",
...
MODULE_DEVICE_TABLE(of, korina_match);
which builds
$ objdump -t drivers/net/ethernet/korina.o | grep __mod_device_table
0000000000001020 l O .rodata 0000000000000190
__mod_device_table__kmod_korina__of__korina_match
$ objdump -s -j .rodata --start-address=0x1020
--stop-address=$((0x1020+0x190)) drivers/net/ethernet/korina.o
...
1020 00000000 00000000 00000000 00000000 ................
1030 00000000 00000000 00000000 00000000 ................
1040 00000000 00000000 00000000 00000000 ................
1050 00000000 00000000 00000000 00000000 ................
1060 6964742c 33323433 782d656d 61630000 idt,3243x-emac..
1070 00000000 00000000 00000000 00000000 ................
...
@ scripts/mod/file2lias.c
#define DEF_FIELD_ADDR(m, devid, f) \
typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f)
static void do_of_entry(struct module *mod, void *symval)
{
...
DEF_FIELD_ADDR(symval, of_device_id, compatible);
...
void handle_moddevtable(struct module *mod, struct elf_info *info,
Elf_Sym *sym, const char *symname)
{
void *symval;
...
symval = sym_get_data(info, sym);
On the other hand, a pointer is stored indirectly through a relocation
in the symbol, which is not as simple to read (i.e., 1. find the
relocation section for the symbol's section; 2. find the relocation in
that section by matching relocation offsets with an offset in the symbol
+ symbol address; 3. finally read the relocation's target).
>> > I would be great if your series didn't introduce a new obstacle for
>> > [CHERI].
>>
>> Absolutely. I'll be happy to adjust the series and testing for that.
>>
>> Could you please confirm one should just follow [1], which uses [2] to
>> build the LLVM toolchain, and use it to build the kernel [3]?
>>
>> [1] https://github.com/cheri-linux#building-and-running
>> [2] https://github.com/cheri-linux/buildroot
>> [3] https://github.com/CHERI-Alliance/linux/tree/codasip-cheri-riscv-7.1
>
> I used
> https://github.com/CHERI-Alliance/meta-cheri/tree/codasip-scarthgap and
> didn't care about toolchain and rootfs. It also has qemu integrated, so
> you can actually test it.
I'll take a look; thanks!
cheers,
>
> Best regards
> Uwe
--
Mauricio
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-08-25 19:10 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 18:16 [PATCH RFC v3 00/13] sysctl: add module aliases Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:16 ` [PATCH RFC v3 01/13] keys, pidns, fs/verity, riscv/vector: reorder '#include <linux/sysctl.h>' Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:20 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 02/13] proc: add config option SYSCTL_MODULE_ALIASES Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:24 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 03/13] sysctl, mod_devicetable: add macro MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:32 ` sashiko-bot
2026-08-22 13:41 ` Uwe Kleine-König
2026-08-22 13:41 ` Uwe Kleine-König
2026-08-22 16:57 ` Mauricio Faria de Oliveira
2026-08-22 16:57 ` Mauricio Faria de Oliveira
2026-08-23 22:12 ` Uwe Kleine-König
2026-08-23 22:12 ` Uwe Kleine-König
2026-08-24 21:04 ` Mauricio Faria de Oliveira
2026-08-24 21:04 ` Mauricio Faria de Oliveira
2026-08-25 8:24 ` Uwe Kleine-König
2026-08-25 8:24 ` Uwe Kleine-König
2026-08-25 19:10 ` Mauricio Faria de Oliveira [this message]
2026-08-25 19:10 ` Mauricio Faria de Oliveira
2026-08-19 18:16 ` [PATCH RFC v3 04/13] sysctl: add register_sysctl() wrapper for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:34 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 05/13] sysctl, parport: update register_sysctl() callers with template arguments Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:24 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 06/13] sysctl, net: add register_net_sysctl{_sz}() wrappers for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:25 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 07/13] sysctl, net: update register_net_sysctl{_sz}() callers with template arguments Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:33 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 08/13] sysctl, net: update register_net_sysctl_sz(ARRAY_SIZE(table_tmpl)) " Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:26 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 09/13] sysctl, ipv6: update register_net_sysctl{_sz}() callers " Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:24 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 10/13] sysctl, net: update register_net_sysctl_sz() edge case Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:24 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 11/13] sysctl: unrandomize struct ctl_table.procname Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:26 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 12/13] modpost: move addend_*_rel() calls into addend_rel() Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:26 ` sashiko-bot
2026-08-19 18:16 ` [PATCH RFC v3 13/13] modpost: handle MODULE_SYSCTL_TABLE symbols Mauricio Faria de Oliveira
2026-08-19 18:16 ` Mauricio Faria de Oliveira
2026-08-19 18:35 ` sashiko-bot
2026-08-20 12:51 ` [PATCH RFC v3 00/13] sysctl: add module aliases Joel Granados
2026-08-20 12:51 ` Joel Granados
2026-08-20 21:22 ` Mauricio Faria de Oliveira
2026-08-20 21:22 ` Mauricio Faria de Oliveira
2026-09-04 13:41 ` Joel Granados
2026-09-04 13:41 ` Joel Granados
2026-09-04 17:45 ` Mauricio Faria de Oliveira
2026-09-04 17:45 ` Mauricio Faria de Oliveira
2026-09-09 14:07 ` Joel Granados
2026-09-09 14:07 ` Joel Granados
2026-09-09 17:29 ` Mauricio Faria de Oliveira
2026-09-09 17:29 ` Mauricio Faria de Oliveira
2026-09-10 7:29 ` Joel Granados
2026-09-10 7:29 ` Joel Granados
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=4a7925a800f0c9b36078a70bf35e960d@igalia.com \
--to=mfo@igalia.com \
--cc=bpf@vger.kernel.org \
--cc=bridge@lists.linux.dev \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fsverity@lists.linux.dev \
--cc=horms@kernel.org \
--cc=joel.granados@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-dev@igalia.com \
--cc=keyrings@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=lvs-devel@vger.kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=nsc@kernel.org \
--cc=pabeni@redhat.com \
--cc=rds-devel@oss.oracle.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=virtualization@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.