Skip to contentSkip to conversation

allwinner-h3: Switch to SMC as PSCI conduit

PATCH Applied Alexander Graf 4 participants 4 messages Sep 20, 2021 – Sep 27, 2021 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 allwinner-h3: Switch to SMC as PSCI conduit

The Allwinner H3 SoC uses Cortex-A7 cores which support virtualization. However, today we are configuring QEMU to use HVC as PSCI conduit.

That means HVC calls get trapped into QEMU instead of the guest's own emulated CPU and thus break the guest's ability to execute virtualization.

Fix this by moving to SMC as conduit, freeing up HYP completely to the VM.

Fixes 740dafc0ba0 ("hw/arm: add Allwinner H3 System-on-Chip")
---
 hw/arm/allwinner-h3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/allwinner-h3.c +1 -1
index 27f1070145..f9b7ed1871 100644
@@ -237,7 +237,7 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
 
         /* Provide Power State Coordination Interface */
         qdev_prop_set_int32(DEVICE(&s->cpus[i]), "psci-conduit",
-                            QEMU_PSCI_CONDUIT_HVC);
+                            QEMU_PSCI_CONDUIT_SMC);
 
         /* Disable secondary CPUs */
         qdev_prop_set_bit(DEVICE(&s->cpus[i]), "start-powered-off",
Signature · 1 line
2.30.1 (Apple Git-130)
Reviewed-by Tested-by on v1 1/1
#1 lore raw

Hi Alexander,

I've tested your patch on the acceptance tests and they all pass:

ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado --show=app,console run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py
...
RESULTS : PASS 5 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME : 116.08 s

Also the latest linux kernel is working OK with all cores booting up fine.

At first I couldn't really figure out why simply changing the conduit there works, without also changing the Linux kernel to match.
But it turns out we just override the provided DTB for this in fdt_add_psci_node() in hw/arm/boot.c and the Linux kernel then uses that to decide between HVC and SMC.

So looks fine to me:

Regards,
Niek

Quoted 32 lines · Alexander Graf

The Allwinner H3 SoC uses Cortex-A7 cores which support virtualization. However, today we are configuring QEMU to use HVC as PSCI conduit.

That means HVC calls get trapped into QEMU instead of the guest's own emulated CPU and thus break the guest's ability to execute virtualization.

Fix this by moving to SMC as conduit, freeing up HYP completely to the VM.

Fixes 740dafc0ba0 ("hw/arm: add Allwinner H3 System-on-Chip")
---
 hw/arm/allwinner-h3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/allwinner-h3.c +1 -1
index 27f1070145..f9b7ed1871 100644
@@ -237,7 +237,7 @@ static void allwinner_h3_realize(DeviceState *dev,
 Error **errp)
 
         /* Provide Power State Coordination Interface */
         qdev_prop_set_int32(DEVICE(&s->cpus[i]), "psci-conduit",
-                            QEMU_PSCI_CONDUIT_HVC);
+                            QEMU_PSCI_CONDUIT_SMC);
 
         /* Disable secondary CPUs */
         qdev_prop_set_bit(DEVICE(&s->cpus[i]), "start-powered-off",

--
2.30.1 (Apple Git-130)

Signature · 1 line
Niek Linnenbank
#2 lore raw
Quoted 10 lines · Niek Linnenbank

Hi Alexander,

I've tested your patch on the acceptance tests and they all pass:

ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado --show=app,console run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py
...
RESULTS : PASS 5 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 116.08 s

Quoted 8 lines

Also the latest linux kernel is working OK with all cores booting up fine.

At first I couldn't really figure out why simply changing the conduit there works, without also changing the Linux kernel to match.
But it turns out we just override the provided DTB for this in fdt_add_psci_node() in hw/arm/boot.c and the Linux kernel then uses that to decide between HVC and SMC.

So looks fine to me:

Applied to target-arm.next, thanks.

PS: if you put spaces in front of 'Reviewed-by' type tags, the automated tooling doesn't recognize them.

-- PMM

Reviewed-by on v1 1/1
#3 lore raw
In reply to Alexander Graf
Quoted 6 lines · Alexander Graf

The Allwinner H3 SoC uses Cortex-A7 cores which support virtualization. However, today we are configuring QEMU to use HVC as PSCI conduit.

That means HVC calls get trapped into QEMU instead of the guest's own emulated CPU and thus break the guest's ability to execute virtualization.

Quoted 7 lines

Fix this by moving to SMC as conduit, freeing up HYP completely to the VM.

Fixes 740dafc0ba0 ("hw/arm: add Allwinner H3 System-on-Chip")
---
 hw/arm/allwinner-h3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)