public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Initial steps to constify irq_chip
@ 2024-11-17  9:49 Christophe JAILLET
  2024-11-17  9:49 ` [PATCH 1/5] irqchip: Constify "struct irq_chip *" parameter in chained_irq_xxx() functions Christophe JAILLET
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Christophe JAILLET @ 2024-11-17  9:49 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, kernel-janitors, Christophe JAILLET

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(-)

-- 
2.47.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-12-03 11:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-17  9:49 [PATCH 0/5] Initial steps to constify irq_chip Christophe JAILLET
2024-11-17  9:49 ` [PATCH 1/5] irqchip: Constify "struct irq_chip *" parameter in chained_irq_xxx() functions Christophe JAILLET
2024-11-17  9:49 ` [PATCH 2/5] irqchip: Constify "struct irq_chip *" parameter in cond_unmask_eoi_irq() Christophe JAILLET
2024-11-17  9:49 ` [PATCH 3/5] irqchip: Constify some direct access to irq_data->chip Christophe JAILLET
2024-11-17  9:49 ` [PATCH 4/5] irqchip: Constify some irq_desc_get_chip() usage Christophe JAILLET
2024-12-03 11:32   ` Thomas Gleixner
2024-11-17  9:49 ` [PATCH 5/5] irqchip: Constify some irq_data_get_irq_chip() usage Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox