Skip to contentSkip to conversation

firmware/psci: Don't register with debugfs if PSCI isn't available

PATCH Applied Marc Zyngier 5 participants 5 messages Jan 5, 2023 – Jan 6, 2023 Power state coordination interface (psci)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware/psci: Don't register with debugfs if PSCI isn't available

Contrary to popular belief, PSCI is not a universal property of an ARM/arm64 system. There is a garden variety of systems out there that don't (or even cannot) implement it.

I'm the first one deplore such a situation, but hey...

On such systems, a "cat /sys/kernel/debug/psci" results in fireworks, as no invocation callback is registered.

Check for the invoke_psci_fn and psci_ops.get_version pointers before registering with the debugfs subsystem, avoiding the issue altogether.

Fixes 3137f2e60098 ("firmware/psci: Add debugfs support to ease debugging")
Cc Dmitry Baryshkov <[email protected]>
Cc Mark Brown <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
---
 drivers/firmware/psci/psci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/firmware/psci/psci.c +3 -0
index e7bcfca4159f..447ee4ea5c90 100644
@@ -440,6 +440,9 @@ static const struct file_operations psci_debugfs_ops = {
 
 static int __init psci_debugfs_init(void)
 {
+	if (!invoke_psci_fn || !psci_ops.get_version)
+		return 0;
+
 	return PTR_ERR_OR_ZERO(debugfs_create_file("psci", 0444, NULL, NULL,
 						   &psci_debugfs_ops));
 }
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Marc Zyngier

Contrary to popular belief, PSCI is not a universal property of an ARM/arm64 system. There is a garden variety of systems out there that don't (or even cannot) implement it.

I'm the first one deplore such a situation, but hey...

On such systems, a "cat /sys/kernel/debug/psci" results in fireworks, as no invocation callback is registered.

Check for the invoke_psci_fn and psci_ops.get_version pointers before registering with the debugfs subsystem, avoiding the issue altogether.

Quoted 9 lines
Fixes 3137f2e60098 ("firmware/psci: Add debugfs support to ease debugging")
Cc Dmitry Baryshkov <[email protected]>
Cc Mark Brown <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>

Mark.

Quoted 21 lines
---
 drivers/firmware/psci/psci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/firmware/psci/psci.c +3 -0
index e7bcfca4159f..447ee4ea5c90 100644
@@ -440,6 +440,9 @@ static const struct file_operations psci_debugfs_ops = {
 
 static int __init psci_debugfs_init(void)
 {
+	if (!invoke_psci_fn || !psci_ops.get_version)
+		return 0;
+
 	return PTR_ERR_OR_ZERO(debugfs_create_file("psci", 0444, NULL, NULL,
 						   &psci_debugfs_ops));
 }
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#2 lore raw
In reply to Marc Zyngier
Quoted 13 lines · Marc Zyngier

Contrary to popular belief, PSCI is not a universal property of an ARM/arm64 system. There is a garden variety of systems out there that don't (or even cannot) implement it.

I'm the first one deplore such a situation, but hey...

On such systems, a "cat /sys/kernel/debug/psci" results in fireworks, as no invocation callback is registered.

Check for the invoke_psci_fn and psci_ops.get_version pointers before registering with the debugfs subsystem, avoiding the issue altogether.

Quoted 9 lines
Fixes 3137f2e60098 ("firmware/psci: Add debugfs support to ease debugging")
Cc Dmitry Baryshkov <[email protected]>
Cc Mark Brown <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 1/1
#3 lore raw
In reply to Marc Zyngier
Quoted 31 lines · Marc Zyngier

Contrary to popular belief, PSCI is not a universal property of an ARM/arm64 system. There is a garden variety of systems out there that don't (or even cannot) implement it.

I'm the first one deplore such a situation, but hey...

On such systems, a "cat /sys/kernel/debug/psci" results in fireworks, as no invocation callback is registered.

Check for the invoke_psci_fn and psci_ops.get_version pointers before registering with the debugfs subsystem, avoiding the issue altogether.

Fixes 3137f2e60098 ("firmware/psci: Add debugfs support to ease debugging")
Cc Dmitry Baryshkov <[email protected]>
Cc Mark Brown <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
---
 drivers/firmware/psci/psci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/firmware/psci/psci.c +0 -0
index e7bcfca4159f..447ee4ea5c90 100644

drivers/firmware/psci/psci.c static const struct file_operations psci_debugfs_ops = { · line 448

Quoted 9 lines
drivers/firmware/psci/psci.c +3 -0
@@ -440,6 +440,9 @@ static const struct file_operations psci_debugfs_ops = {
 
 static int __init psci_debugfs_init(void)
 {
+	if (!invoke_psci_fn || !psci_ops.get_version)
+		return 0;
+
 	return PTR_ERR_OR_ZERO(debugfs_create_file("psci", 0444, NULL, NULL,
 						   &psci_debugfs_ops));
 }

- Hector

Applied
#4 lore raw
In reply to Marc Zyngier
Quoted 10 lines · Marc Zyngier

Contrary to popular belief, PSCI is not a universal property of an ARM/arm64 system. There is a garden variety of systems out there that don't (or even cannot) implement it.

I'm the first one deplore such a situation, but hey...

On such systems, a "cat /sys/kernel/debug/psci" results in fireworks, as no invocation callback is registered.

[...]

Applied to arm64 (for-next/fixes), thanks!

[1/1] firmware/psci: Don't register with debugfs if PSCI isn't available

      https://git.kernel.org/arm64/c/cef139299fd8

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev