Skip to content

Commit

Permalink
[vcos:feature] armv8-r/gicv3: disable 64bits access gic 64bits registers
Browse files Browse the repository at this point in the history
When neon is enabled, compiler may optimize 64bits access to vstr, that
will cause data aborts.
Split 64bits access to double 32bits access for GIC_IROUTER/GICR_TYPER,
just like linux.

Feishu-Url:
https://project.feishu.cn/vehicle_control/story/detail/4421235620

Change-Id: I3cc5e19cd7c33395ad5cb4cdd4ab56d4f498c131
Signed-off-by: Jinliang Li <[email protected]>
  • Loading branch information
jinliangli committed Sep 6, 2024
1 parent 831b979 commit 1cc9088
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions arch/arm/src/armv8-r/arm_gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ static inline void arm_gic_write_irouter(uint64_t val, unsigned int intid)
{
unsigned long addr = IROUTER(GET_DIST_BASE(intid), intid);

putreg64(val, addr);
/* Use two putreg32 instead of one putreg64, because when the neon option
* is enabled, the compiler may optimize putreg64 to the neon vstr
* instruction, which will cause a data abort.
*/
putreg32((uint32_t)val, addr);
putreg32((uint32_t)(val >> 32) , addr + 4);
}

void arm_gic_irq_set_priority(unsigned int intid, unsigned int prio,
Expand Down Expand Up @@ -779,7 +784,12 @@ static int gic_validate_redist_version(void)
return -ENODEV;
}

typer = getreg64(redist_base + GICR_TYPER);
/* In AArch32, use 32bits accesses GICR_TYPER, in case that nuttx
* run as vm, and hypervisor doesn't emulation strd.
* Just like linux and zephyr.
*/
typer = getreg32(redist_base + GICR_TYPER);
typer |= (uint64_t)getreg32(redist_base + GICR_TYPER + 4) << 32;
has_vlpis &= !!(typer & GICR_TYPER_VLPIS);
has_direct_lpi &= !!(typer & GICR_TYPER_DIRECTLPIS);
ppi_nr = MIN(GICR_TYPER_NR_PPIS(typer), ppi_nr);
Expand Down

0 comments on commit 1cc9088

Please sign in to comment.