Skip to content

Initial steps to constify irq_chip

Christophe JAILLET kernel-janitors lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5irqchip: Constify "struct irq_chip *" parameter in chained_irq_xxx() functionsinclude/linux/irqchip/chained_irq.h+2 -20 replies
2/5irqchip: Constify "struct irq_chip *" parameter in cond_unmask_eoi_irq()kernel/irq/chip.c+2 -10 replies
3/5irqchip: Constify some direct access to irq_data->chipkernel/irq/chip.c kernel/irq/debugfs.c kernel/irq/manage.c +1 more+11 -110 replies
4/5irqchip: Constify some irq_desc_get_chip() usagekernel/irq/chip.c+5 -51 reply
5/5irqchip: Constify some irq_data_get_irq_chip() usagekernel/irq/chip.c kernel/irq/cpuhotplug.c kernel/irq/manage.c+9 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] Initial steps to constify irq_chip

struct irq_chip holds many function pointers and so, is a good candidate for constification.

Some steps to constify these structures have already been done in 2022 with commit 393e1280f765 ("genirq: Allow irq_chip registration functions to take a const irq_chip") and ef6e5d61eb7a ("genirq: Allow irq_set_chip_handler_name_locked() to take a const irq_chip")

However these commits introduce some ugly casting to store some const parameters into non-const struct members. [1] [2]

The goal of this serie is to try to go further, and eventually cleanly constify irq_chip. As a consequence, it will increase the overall security, because of the constification of some function pointers.

Based on elixir, it is referenced in 565 files. [3]
So, the road looks long because this structure is used in many places.

It will need to constify the return value of irq_get_chip(), irq_data_get_irq_chip() and irq_desc_get_chip() which are widely used. It is expected that many other functions may need to be tweaked in order to propagate this const qualifier where needed in call chains.

So, let start somewhere and see how far we can go :)

patch 1 and 2 only update the prototypes of some functions and should be straightforward.

The 3 other patches update some variable declaration in kernel/irq/ I have split the patches according to the way a reference to a struct irq_chip is gotten.

This serie may be invasive and touch many places to get rid of the ugly castings, but as least patch 1 and 2 should IMHO be merged because they are simple and go in the right direction.

The 3 other ones, and all the oher ones that will be needed, may not need the effort.

Before going further, feedback is aoppreciated

CJ

[1]: https://elixir.bootlin.com/linux/v6.12-rc7/source/kernel/irq/chip.c#L49
[2]: https://elixir.bootlin.com/linux/v6.12-rc7/source/include/linux/irqdesc.h#L236
[3]: https://elixir.bootlin.com/linux/v6.12-rc7/A/ident/irq_chip

Christophe JAILLET (5):
irqchip: Constify "struct irq_chip *" parameter in chained_irq_xxx()
functions
irqchip: Constify "struct irq_chip *" parameter in
cond_unmask_eoi_irq()
irqchip: Constify some direct access to irq_data->chip
irqchip: Constify some irq_desc_get_chip() usage
irqchip: Constify some irq_data_get_irq_chip() usage

 include/linux/irqchip/chained_irq.h |  4 ++--
 kernel/irq/chip.c                   | 25 +++++++++++++------------
 kernel/irq/cpuhotplug.c             |  2 +-
 kernel/irq/debugfs.c                |  2 +-
 kernel/irq/manage.c                 | 20 ++++++++++----------
 kernel/irq/migration.c              |  2 +-
 6 files changed, 28 insertions(+), 27 deletions(-)
Signature · 1 line
2.47.0