From aaea4e0f0e645dbf4a6c04c60517df11d6a391f8 Mon Sep 17 00:00:00 2001 From: ouyangxiangzhen Date: Thu, 7 Nov 2024 19:55:41 +0800 Subject: [PATCH] arch/arm64: Optimized SGI to avoid VM exit. In the virtualized environment, each time an SGI is sent, the value of IGROUPR0 needs to be read once. Since the GIC Redistributor is a purely emulated device, each read of IGROUPR0 will cause a VM exit, causing serious performance degradation. This patch replaces the read with the value previously set in `gicv3_cpuif_init`, and we assume that this value has not been modified after initialization. Signed-off-by: ouyangxiangzhen --- arch/arm64/src/common/arm64_gicv3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/src/common/arm64_gicv3.c b/arch/arm64/src/common/arm64_gicv3.c index 74b28599661..3852fd1c06e 100644 --- a/arch/arm64/src/common/arm64_gicv3.c +++ b/arch/arm64/src/common/arm64_gicv3.c @@ -378,9 +378,7 @@ static int arm64_gic_send_sgi(unsigned int sgi_id, uint64_t target_aff, uint32_t aff1; uint64_t sgi_val; uint32_t regval; - unsigned long base; - base = gic_get_rdist() + GICR_SGI_BASE_OFF; ASSERT(GIC_IS_SGI(sgi_id)); /* Extract affinity fields from target */ @@ -394,7 +392,9 @@ static int arm64_gic_send_sgi(unsigned int sgi_id, uint64_t target_aff, ARM64_DSB(); - regval = getreg32(IGROUPR(base, 0)); + /* Read the IGROUPR0 value we set in `gicv3_cpuif_init` */ + + regval = IGROUPR_SGI_VAL; if (regval & BIT(sgi_id)) {