[PATCH 3/4] syscon: Wire up has-inaccessible-regs

Richard Weinberger posted 4 patches 2 days, 8 hours ago
[PATCH 3/4] syscon: Wire up has-inaccessible-regs
Posted by Richard Weinberger 2 days, 8 hours ago
Evaluate the has-inaccessible-regs device tree property to disable
debugfs access if a register map contains dangerous/harmful registers.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mfd/syscon.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index ae71a2710bed8..73fff0df3f42f 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -70,6 +70,16 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
 	else if (of_property_read_bool(np, "native-endian"))
 		syscon_config.val_format_endian = REGMAP_ENDIAN_NATIVE;
 
+
+	/*
+	 * Disable debugfs access if a register map has various inaccessible
+	 * registers.
+	 * In such a case the device driver has to know exactly how and when
+	 * access is allowed but general access via userspace can cause harm.
+	 */
+	if (of_property_read_bool(np, "has-inaccessible-regs"))
+		syscon_config.debugfs_disable = true;
+
 	/*
 	 * search for reg-io-width property in DT. If it is not provided,
 	 * default to 4 bytes. regmap_init_mmio will return an error if values
-- 
2.51.0
Re: [PATCH 3/4] syscon: Wire up has-inaccessible-regs
Posted by Krzysztof Kozlowski 2 days, 7 hours ago
On 29/11/2025 15:20, Richard Weinberger wrote:
> Evaluate the has-inaccessible-regs device tree property to disable
> debugfs access if a register map contains dangerous/harmful registers.
> 
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
>  drivers/mfd/syscon.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index ae71a2710bed8..73fff0df3f42f 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -70,6 +70,16 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
>  	else if (of_property_read_bool(np, "native-endian"))
>  		syscon_config.val_format_endian = REGMAP_ENDIAN_NATIVE;
>  
> +
> +	/*
> +	 * Disable debugfs access if a register map has various inaccessible
> +	 * registers.
> +	 * In such a case the device driver has to know exactly how and when
> +	 * access is allowed but general access via userspace can cause harm.
> +	 */
> +	if (of_property_read_bool(np, "has-inaccessible-regs"))
> +		syscon_config.debugfs_disable = true;

So you mark ENTIRE device like that? Then you don't need the property.
Your compatible already tells you that (IOW, this is fully deducible
from the compatible).

Best regards,
Krzysztof