All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] allwinner-h3: Switch to SMC as PSCI conduit
@ 2021-09-20 20:39 Alexander Graf
  2021-09-22 19:41 ` Niek Linnenbank
  2021-09-27 11:05 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Graf @ 2021-09-20 20:39 UTC (permalink / raw)
  To: QEMU Developers
  Cc: Beniamino Galvani, Peter Maydell, Niek Linnenbank, qemu-arm,
	Philippe Mathieu-Daudé

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.

Signed-off-by: Alexander Graf <agraf@csgraf.de>
Fixes: 740dafc0ba0 ("hw/arm: add Allwinner H3 System-on-Chip")
---
 hw/arm/allwinner-h3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
index 27f1070145..f9b7ed1871 100644
--- a/hw/arm/allwinner-h3.c
+++ b/hw/arm/allwinner-h3.c
@@ -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)



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] allwinner-h3: Switch to SMC as PSCI conduit
  2021-09-20 20:39 [PATCH] allwinner-h3: Switch to SMC as PSCI conduit Alexander Graf
@ 2021-09-22 19:41 ` Niek Linnenbank
  2021-09-27 10:11   ` Peter Maydell
  2021-09-27 11:05 ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 4+ messages in thread
From: Niek Linnenbank @ 2021-09-22 19:41 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Beniamino Galvani, Peter Maydell, qemu-arm,
	Philippe Mathieu-Daudé,
	QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 2181 bytes --]

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:
  Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
  Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>

Regards,
Niek

On Mon, Sep 20, 2021 at 10:39 PM Alexander Graf <agraf@csgraf.de> wrote:

> 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.
>
> Signed-off-by: Alexander Graf <agraf@csgraf.de>
> Fixes: 740dafc0ba0 ("hw/arm: add Allwinner H3 System-on-Chip")
> ---
>  hw/arm/allwinner-h3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 27f1070145..f9b7ed1871 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -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)
>
>

-- 
Niek Linnenbank

[-- Attachment #2: Type: text/html, Size: 3160 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] allwinner-h3: Switch to SMC as PSCI conduit
  2021-09-22 19:41 ` Niek Linnenbank
@ 2021-09-27 10:11   ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2021-09-27 10:11 UTC (permalink / raw)
  To: Niek Linnenbank
  Cc: Beniamino Galvani, Alexander Graf, Philippe Mathieu-Daudé,
	QEMU Developers, qemu-arm

On Wed, 22 Sept 2021 at 20:41, Niek Linnenbank <nieklinnenbank@gmail.com> wrote:
>
> 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:
>   Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
>   Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] allwinner-h3: Switch to SMC as PSCI conduit
  2021-09-20 20:39 [PATCH] allwinner-h3: Switch to SMC as PSCI conduit Alexander Graf
  2021-09-22 19:41 ` Niek Linnenbank
@ 2021-09-27 11:05 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-27 11:05 UTC (permalink / raw)
  To: Alexander Graf, QEMU Developers
  Cc: Beniamino Galvani, Peter Maydell, Niek Linnenbank, qemu-arm

On 9/20/21 22:39, Alexander Graf wrote:
> 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.
> 
> Signed-off-by: Alexander Graf <agraf@csgraf.de>
> Fixes: 740dafc0ba0 ("hw/arm: add Allwinner H3 System-on-Chip")
> ---
>  hw/arm/allwinner-h3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-27 11:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 20:39 [PATCH] allwinner-h3: Switch to SMC as PSCI conduit Alexander Graf
2021-09-22 19:41 ` Niek Linnenbank
2021-09-27 10:11   ` Peter Maydell
2021-09-27 11:05 ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.