Skip to content

Commit 46671fd

Browse files
committed
Merge tag 'stm32-bus-firewall-for-v6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/atorgue/stm32 into soc/drivers
STM32 Firewall bus for v6.10, round 1 Highlights: --------- Introduce STM32 Firewall framework for STM32MP1x and STM32MP2x platforms. STM32MP1x(ETZPC) and STM32MP2x(RIFSC) Firewall controllers register to the framework to offer firewall services such as access granting. This series of patches is a new approach on the previous STM32 system bus, history is available here: https://lore.kernel.org/lkml/20230127164040.1047583/ The need for such framework arises from the fact that there are now multiple hardware firewalls implemented across multiple products. Drivers are shared between different products, using the same code. When it comes to firewalls, the purpose mostly stays the same: Protect hardware resources. But the implementation differs, and there are multiple types of firewalls: peripheral, memory, ... Some hardware firewall controllers such as the RIFSC implemented on STM32MP2x platforms may require to take ownership of a resource before being able to use it, hence the requirement for firewall services to take/release the ownership of such resources. On the other hand, hardware firewall configurations are becoming more and more complex. These mecanisms prevent platform crashes or other firewall-related incoveniences by denying access to some resources. The stm32 firewall framework offers an API that is defined in firewall controllers drivers to best fit the specificity of each firewall. For every peripherals protected by either the ETZPC or the RIFSC, the firewall framework checks the firewall controlelr registers to see if the peripheral's access is granted to the Linux kernel. If not, the peripheral is configured as secure, the node is marked populated, so that the driver is not probed for that device. The firewall framework relies on the access-controller device tree binding. It is used by peripherals to reference a domain access controller. In this case a firewall controller. The bus uses the ID referenced by the access-controller property to know where to look in the firewall to get the security configuration for the peripheral. This allows a device tree description rather than a hardcoded peripheral table in the bus driver. The STM32 ETZPC device is responsible for filtering accesses based on security level, or co-processor isolation for any resource connected to it. The RIFSC is responsible for filtering accesses based on Compartment ID / security level / privilege level for any resource connected to it. * tag 'stm32-bus-firewall-for-v6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/atorgue/stm32: bus: stm32_firewall: fix off by one in stm32_firewall_get_firewall() bus: etzpc: introduce ETZPC firewall controller driver bus: rifsc: introduce RIFSC firewall controller driver of: property: fw_devlink: Add support for "access-controller" firewall: introduce stm32_firewall framework dt-bindings: bus: document ETZPC dt-bindings: bus: document RIFSC dt-bindings: treewide: add access-controllers description dt-bindings: document generic access controllers Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 29a7020 + e4500d7 commit 46671fd

40 files changed

+1323
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/access-controllers/access-controllers.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Generic Domain Access Controllers
8+
9+
maintainers:
10+
- Oleksii Moisieiev <[email protected]>
11+
12+
description: |+
13+
Common access controllers properties
14+
15+
Access controllers are in charge of stating which of the hardware blocks under
16+
their responsibility (their domain) can be accesssed by which compartment. A
17+
compartment can be a cluster of CPUs (or coprocessors), a range of addresses
18+
or a group of hardware blocks. An access controller's domain is the set of
19+
resources covered by the access controller.
20+
21+
This device tree binding can be used to bind devices to their access
22+
controller provided by access-controllers property. In this case, the device
23+
is a consumer and the access controller is the provider.
24+
25+
An access controller can be represented by any node in the device tree and
26+
can provide one or more configuration parameters, needed to control parameters
27+
of the consumer device. A consumer node can refer to the provider by phandle
28+
and a set of phandle arguments, specified by '#access-controller-cells'
29+
property in the access controller node.
30+
31+
Access controllers are typically used to set/read the permissions of a
32+
hardware block and grant access to it. Any of which depends on the access
33+
controller. The capabilities of each access controller are defined by the
34+
binding of the access controller device.
35+
36+
Each node can be a consumer for the several access controllers.
37+
38+
# always select the core schema
39+
select: true
40+
41+
properties:
42+
"#access-controller-cells":
43+
description:
44+
Number of cells in an access-controllers specifier;
45+
Can be any value as specified by device tree binding documentation
46+
of a particular provider. The node is an access controller.
47+
48+
access-controller-names:
49+
$ref: /schemas/types.yaml#/definitions/string-array
50+
description:
51+
A list of access-controllers names, sorted in the same order as
52+
access-controllers entries. Consumer drivers will use
53+
access-controller-names to match with existing access-controllers entries.
54+
55+
access-controllers:
56+
$ref: /schemas/types.yaml#/definitions/phandle-array
57+
description:
58+
A list of access controller specifiers, as defined by the
59+
bindings of the access-controllers provider.
60+
61+
additionalProperties: true
62+
63+
examples:
64+
- |
65+
clock_controller: access-controllers@50000 {
66+
reg = <0x50000 0x400>;
67+
#access-controller-cells = <2>;
68+
};
69+
70+
bus_controller: bus@60000 {
71+
reg = <0x60000 0x10000>;
72+
#address-cells = <1>;
73+
#size-cells = <1>;
74+
ranges;
75+
#access-controller-cells = <3>;
76+
77+
uart4: serial@60100 {
78+
reg = <0x60100 0x400>;
79+
clocks = <&clk_serial>;
80+
access-controllers = <&clock_controller 1 2>,
81+
<&bus_controller 1 3 5>;
82+
access-controller-names = "clock", "bus";
83+
};
84+
};
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/bus/st,stm32-etzpc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: STM32 Extended TrustZone protection controller
8+
9+
description: |
10+
The ETZPC configures TrustZone security in a SoC having bus masters and
11+
devices with programmable-security attributes (securable resources).
12+
13+
maintainers:
14+
- Gatien Chevallier <[email protected]>
15+
16+
select:
17+
properties:
18+
compatible:
19+
contains:
20+
const: st,stm32-etzpc
21+
required:
22+
- compatible
23+
24+
properties:
25+
compatible:
26+
items:
27+
- const: st,stm32-etzpc
28+
- const: simple-bus
29+
30+
reg:
31+
maxItems: 1
32+
33+
"#address-cells":
34+
const: 1
35+
36+
"#size-cells":
37+
const: 1
38+
39+
ranges: true
40+
41+
"#access-controller-cells":
42+
const: 1
43+
description:
44+
Contains the firewall ID associated to the peripheral.
45+
46+
patternProperties:
47+
"^.*@[0-9a-f]+$":
48+
description: Peripherals
49+
type: object
50+
51+
additionalProperties: true
52+
53+
required:
54+
- access-controllers
55+
56+
required:
57+
- compatible
58+
- reg
59+
- "#address-cells"
60+
- "#size-cells"
61+
- "#access-controller-cells"
62+
- ranges
63+
64+
additionalProperties: false
65+
66+
examples:
67+
- |
68+
// In this example, the usart2 device refers to rifsc as its access
69+
// controller.
70+
// Access rights are verified before creating devices.
71+
72+
#include <dt-bindings/interrupt-controller/arm-gic.h>
73+
#include <dt-bindings/clock/stm32mp13-clks.h>
74+
#include <dt-bindings/reset/stm32mp13-resets.h>
75+
76+
etzpc: bus@5c007000 {
77+
compatible = "st,stm32-etzpc", "simple-bus";
78+
reg = <0x5c007000 0x400>;
79+
#address-cells = <1>;
80+
#size-cells = <1>;
81+
#access-controller-cells = <1>;
82+
ranges;
83+
84+
usart2: serial@4c001000 {
85+
compatible = "st,stm32h7-uart";
86+
reg = <0x4c001000 0x400>;
87+
interrupts-extended = <&exti 27 IRQ_TYPE_LEVEL_HIGH>;
88+
clocks = <&rcc USART2_K>;
89+
resets = <&rcc USART2_R>;
90+
wakeup-source;
91+
dmas = <&dmamux1 43 0x400 0x5>,
92+
<&dmamux1 44 0x400 0x1>;
93+
dma-names = "rx", "tx";
94+
access-controllers = <&etzpc 17>;
95+
};
96+
};
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/bus/st,stm32mp25-rifsc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: STM32 Resource isolation framework security controller
8+
9+
maintainers:
10+
- Gatien Chevallier <[email protected]>
11+
12+
description: |
13+
Resource isolation framework (RIF) is a comprehensive set of hardware blocks
14+
designed to enforce and manage isolation of STM32 hardware resources like
15+
memory and peripherals.
16+
17+
The RIFSC (RIF security controller) is composed of three sets of registers,
18+
each managing a specific set of hardware resources:
19+
- RISC registers associated with RISUP logic (resource isolation device unit
20+
for peripherals), assign all non-RIF aware peripherals to zero, one or
21+
any security domains (secure, privilege, compartment).
22+
- RIMC registers: associated with RIMU logic (resource isolation master
23+
unit), assign all non RIF-aware bus master to one security domain by
24+
setting secure, privileged and compartment information on the system bus.
25+
Alternatively, the RISUP logic controlling the device port access to a
26+
peripheral can assign target bus attributes to this peripheral master port
27+
(supported attribute: CID).
28+
- RISC registers associated with RISAL logic (resource isolation device unit
29+
for address space - Lite version), assign address space subregions to one
30+
security domains (secure, privilege, compartment).
31+
32+
select:
33+
properties:
34+
compatible:
35+
contains:
36+
const: st,stm32mp25-rifsc
37+
required:
38+
- compatible
39+
40+
properties:
41+
compatible:
42+
items:
43+
- const: st,stm32mp25-rifsc
44+
- const: simple-bus
45+
46+
reg:
47+
maxItems: 1
48+
49+
"#address-cells":
50+
const: 1
51+
52+
"#size-cells":
53+
const: 1
54+
55+
ranges: true
56+
57+
"#access-controller-cells":
58+
const: 1
59+
description:
60+
Contains the firewall ID associated to the peripheral.
61+
62+
patternProperties:
63+
"^.*@[0-9a-f]+$":
64+
description: Peripherals
65+
type: object
66+
67+
additionalProperties: true
68+
69+
required:
70+
- access-controllers
71+
72+
required:
73+
- compatible
74+
- reg
75+
- "#address-cells"
76+
- "#size-cells"
77+
- "#access-controller-cells"
78+
- ranges
79+
80+
additionalProperties: false
81+
82+
examples:
83+
- |
84+
// In this example, the usart2 device refers to rifsc as its domain
85+
// controller.
86+
// Access rights are verified before creating devices.
87+
88+
#include <dt-bindings/interrupt-controller/arm-gic.h>
89+
90+
rifsc: bus@42080000 {
91+
compatible = "st,stm32mp25-rifsc", "simple-bus";
92+
reg = <0x42080000 0x1000>;
93+
#address-cells = <1>;
94+
#size-cells = <1>;
95+
#access-controller-cells = <1>;
96+
ranges;
97+
98+
usart2: serial@400e0000 {
99+
compatible = "st,stm32h7-uart";
100+
reg = <0x400e0000 0x400>;
101+
interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>;
102+
clocks = <&ck_flexgen_08>;
103+
access-controllers = <&rifsc 32>;
104+
};
105+
};

Documentation/devicetree/bindings/crypto/st,stm32-cryp.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ properties:
4646
power-domains:
4747
maxItems: 1
4848

49+
access-controllers:
50+
minItems: 1
51+
maxItems: 2
52+
4953
required:
5054
- compatible
5155
- reg

Documentation/devicetree/bindings/crypto/st,stm32-hash.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ properties:
5151
power-domains:
5252
maxItems: 1
5353

54+
access-controllers:
55+
minItems: 1
56+
maxItems: 2
57+
5458
required:
5559
- compatible
5660
- reg

Documentation/devicetree/bindings/dma/st,stm32-dma.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ properties:
8282
description: if defined, it indicates that the controller
8383
supports memory-to-memory transfer
8484

85+
access-controllers:
86+
minItems: 1
87+
maxItems: 2
88+
8589
required:
8690
- compatible
8791
- reg

Documentation/devicetree/bindings/dma/st,stm32-dmamux.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ properties:
2828
resets:
2929
maxItems: 1
3030

31+
access-controllers:
32+
minItems: 1
33+
maxItems: 2
34+
3135
required:
3236
- compatible
3337
- reg

Documentation/devicetree/bindings/i2c/st,stm32-i2c.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ properties:
127127

128128
wakeup-source: true
129129

130+
access-controllers:
131+
minItems: 1
132+
maxItems: 2
133+
130134
required:
131135
- compatible
132136
- reg

Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ properties:
9393
'#size-cells':
9494
const: 0
9595

96+
access-controllers:
97+
minItems: 1
98+
maxItems: 2
99+
96100
allOf:
97101
- if:
98102
properties:

Documentation/devicetree/bindings/iio/adc/st,stm32-dfsdm-adc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ properties:
5959
If not, SPI CLKOUT frequency will not be accurate.
6060
maximum: 20000000
6161

62+
access-controllers:
63+
minItems: 1
64+
maxItems: 2
65+
6266
required:
6367
- compatible
6468
- reg

0 commit comments

Comments
 (0)