arm: mach-k3: remove some firewalls left over by ROM
Subsystems (2)
cover arm: mach-k3: remove some firewalls left over by ROM
Hello everyone!
This small series is here to remove some firewalls setup by ROM during their boot and clean things up for Linux later on. Ideally this would be a simple call to remove_fwl_configs() however the location of the firewall is problematic (could potentially crash the core) when we're currently executing from the memory region protected by the firewall.
So we need to introduce a function which allows us to disable specific firewall regions and skip others to ensure boot stability.
Happy Hacking
~Bryan
---
Bryan Brattlof (2):
arm: mach-k3: support disabling a single firewall region
arm: mach-k3: am625: remove any firewalls ROM has configured for HSRAM
arch/arm/mach-k3/am62x/am625_init.c | 12 ++++++++++++ arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/r5/common.c | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+)
---
base-commit: 739ad58dbee874a3ad3bddd116e995212a254e07
change-id: 20250326-firewalls-02652f48dbca
Best regards,
Signature · 1 line
Bryan Brattlof <[email protected]>
PATCH 1/2 arm: mach-k3: support disabling a single firewall region
During boot some firewall regions could contain the R5's code which if we change the firewalls settings will crash the core. To get around this issue, define a new function which allows us to specify specific regions we want unlocked.
--- arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/r5/common.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
arch/arm/mach-k3/common.h +1 -0
@@ -35,6 +35,7 @@ enum k3_device_type {void setup_k3_mpu_regions (void );int early_console_init (void );void disable_linefill_optimization (void ); +int remove_fwl_region (struct fwl_data *fwl);void remove_fwl_configs (struct fwl_data *fwl_data,size_t fwl_data_size);int load_firmware (char *name_fw,char *name_loadaddr,u32 *loadaddr);void k3_sysfw_print_ver (void );
arch/arm/mach-k3/r5/common.c +25 -0
@@ -253,6 +253,31 @@ void disable_linefill_optimization(void) asm("mcr p15, 0, %0, c1, c0, 1" : :"r" (actlr)); } +int remove_fwl_region (struct fwl_data *fwl) +{ +struct ti_sci_handle *sci =get_ti_sci_handle (); +struct ti_sci_fwl_ops *ops = &sci->ops.fwl_ops; +struct ti_sci_msg_fwl_region region; +int ret; + + region.fwl_id = fwl->fwl_id; + region.region = fwl->regions; + region.n_permission_regs =3 ; + + ops->get_fwl_region (sci, ®ion); + +/* zero out the enable field of the firewall */ + region.control = region.control & ~0xF ; + +pr_debug ("Disabling firewall id: %d region: %d\n" , + region.fwl_id, region.region); + + ret = ops->set_fwl_region (sci, ®ion); +if (ret) +pr_err ("Could not disable firewall\n" ); +return ret; +} +static void remove_fwl_regions (struct fwl_data fwl_data,size_t num_regions,enum k3_firewall_region_type fwl_type) {
Signature · 1 line
2.48.1
PATCH 2/2 arm: mach-k3: am625: remove any firewalls ROM has configured for HSRAM
In reply to Bryan BrattlofROM will configure a firewall to only allow HSRAM to be touched by the R5 core. Any outside entity like DMA or the A53s will not have access to this region. This can be problematic when U-Boot, running on the A53, loads firmware that runs out of this region.
To simplify things remove the firewall here and let the remote core firmware place a new firewall themselves if they wish for the memory region.
--- arch/arm/mach-k3/am62x/am625_init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/mach-k3/am62x/am625_init.c +12 -0
@@ -29,6 +29,12 @@/* TISCI DEV ID for A53 Clock */ #define AM62X_DEV_A53SS0_CORE_0_DEV_ID 135 +struct fwl_data rom_fwls[] = { + {"SOC_DEVGRP_MAIN" ,641 ,1 }, + {"SOC_DEVGRP_MAIN" ,642 ,1 }, + {"SOC_DEVGRP_MAIN" ,642 ,2 }, +}; +/* * This uninitialized global variable would normal end up in the .bss section, * but the .bss is cleared between writing and reading this variable, so move
@@ -177,6 +183,7 @@ void board_init_f(ulong dummy) {struct udevice *dev;int ret; +int i;if (IS_ENABLED (CONFIG_CPU_V7R )) {setup_k3_mpu_regions ();
@@ -261,6 +268,11 @@ void board_init_f(ulong dummy)/* Output System Firmware version info */ k3_sysfw_print_ver (); +/* Disable firewalls ROM has configured. */ +if (IS_ENABLED (CONFIG_CPU_V7R )) +for (i =0 ; i <ARRAY_SIZE (rom_fwls); i++) +remove_fwl_region (&rom_fwls[i]); +if (IS_ENABLED (CONFIG_ESM_K3 )) {/* Probe/configure ESM0 */ ret =uclass_get_device_by_name (UCLASS_MISC ,"esm@420000" , &dev);
Signature · 1 line
2.48.1
Quoted 10 lines · Bryan Brattlof
This small series is here to remove some firewalls setup by ROM during their boot and clean things up for Linux later on. Ideally this would be a simple call to
remove_fwl_configs()however the location of the firewall is problematic (could potentially crash the core) when we're currently executing from the memory region protected by the firewall.So we need to introduce a function which allows us to disable specific firewall regions and skip others to ensure boot stability.
[...]
Applied to u-boot/master, thanks!
[1/2] arm: mach-k3: support disabling a single firewall region
commit: f393beedba7917ef8aaaedd67d143cd7b7440ae2
[2/2] arm: mach-k3: am625: remove any firewalls ROM has configured for HSRAM
commit: 33b191997fc215e32cd51ffd979c5f6d1189c46eSignature · 1 line
Tom