Skip to content

Commit 0f6d6b2

Browse files
JiafeiPancarlescufi
authored andcommitted
drivers: gicv3: add distributor safe configuration
In case of multiple OSes running on different CPU Cores which share the same GIC controller, need to avoid the distributor re-configured to avoid crash the OS has already been started. Signed-off-by: Jiafei Pan <[email protected]>
1 parent 4fa5fc3 commit 0f6d6b2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

drivers/interrupt_controller/Kconfig.gic

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,14 @@ config GIC_V3_ITS
6363
that ITS uses dynamic memory, so HEAP_MEM_POOL_SIZE should be
6464
enough to allocate ITS tables (size is probed at runtime).
6565

66+
config GIC_SAFE_CONFIG
67+
bool "GIC Distributor Safe Configuration"
68+
depends on GIC_V3
69+
default n
70+
help
71+
In case of multiple OSes running on different CPU Cores which share the
72+
same GIC controller, need to avoid the distributor re-configured to avoid
73+
crash the OS has already been started. With this enabled, it will bypass
74+
GIC distributor configuration if it has been configured by other OS.
75+
6676
endif # CPU_CORTEX

drivers/interrupt_controller/intc_gicv3.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,17 @@ static void gicv3_dist_init(void)
447447
unsigned int idx;
448448
mem_addr_t base = GIC_DIST_BASE;
449449

450+
#ifdef CONFIG_GIC_SAFE_CONFIG
451+
/*
452+
* Currently multiple OSes can run one the different CPU Cores which share single GIC,
453+
* but GIC distributor should avoid to be re-configured in order to avoid crash the
454+
* OSes has already been started.
455+
*/
456+
if (sys_read32(GICD_CTLR) & (BIT(GICD_CTLR_ENABLE_G0) | BIT(GICD_CTLR_ENABLE_G1NS))) {
457+
return;
458+
}
459+
#endif
460+
450461
num_ints = sys_read32(GICD_TYPER);
451462
num_ints &= GICD_TYPER_ITLINESNUM_MASK;
452463
num_ints = (num_ints + 1) << 5;

0 commit comments

Comments
 (0)