Skip to content

Commit 961f740

Browse files
jinlianglianchao
authored andcommitted
armv8-r/gicv3: disable 64bits access gic 64bits registers
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. Signed-off-by: Jinliang Li <lijinliang1@lixiang.com> Signed-off-by: chao an <anchao@lixiang.com>
1 parent 056aa3c commit 961f740

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

arch/arm/src/armv8-r/arm_gicv3.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ static inline void arm_gic_write_irouter(uint64_t val, unsigned int intid)
148148
{
149149
unsigned long addr = IROUTER(GET_DIST_BASE(intid), intid);
150150

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

154160
void arm_gic_irq_set_priority(unsigned int intid, unsigned int prio,
@@ -773,7 +779,13 @@ static int gic_validate_redist_version(void)
773779
return -ENODEV;
774780
}
775781

776-
typer = getreg64(redist_base + GICR_TYPER);
782+
/* In AArch32, use 32bits accesses GICR_TYPER, in case that nuttx
783+
* run as vm, and hypervisor doesn't emulation strd.
784+
* Just like linux and zephyr.
785+
*/
786+
787+
typer = getreg32(redist_base + GICR_TYPER);
788+
typer |= (uint64_t)getreg32(redist_base + GICR_TYPER + 4) << 32;
777789
has_vlpis &= !!(typer & GICR_TYPER_VLPIS);
778790
has_direct_lpi &= !!(typer & GICR_TYPER_DIRECTLPIS);
779791
ppi_nr = MIN(GICR_TYPER_NR_PPIS(typer), ppi_nr);

0 commit comments

Comments
 (0)