[PATCH] arm: Remove HVC dispatching to PSCI services

13 views
Skip to first unread message

Jan Kiszka

unread,
Sep 21, 2016, 1:46:44 AM9/21/16
to Jailhouse
The root cell can't be using HVC dispatching as it can't be running a
hypervisor prior to Jailhouse. And we can tell our non-root cells to use
the SMC method for PSCI services.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm/traps.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/hypervisor/arch/arm/traps.c b/hypervisor/arch/arm/traps.c
index ab5b3a0..4b2cd21 100644
--- a/hypervisor/arch/arm/traps.c
+++ b/hypervisor/arch/arm/traps.c
@@ -264,14 +264,10 @@ static int arch_handle_hvc(struct trap_context *ctx)
unsigned long *regs = ctx->regs;
unsigned long code = regs[0];

- if (IS_PSCI_32(code) || IS_PSCI_UBOOT(code)) {
- regs[0] = psci_dispatch(ctx);
- } else {
- regs[0] = hypercall(code, regs[1], regs[2]);
+ regs[0] = hypercall(code, regs[1], regs[2]);

- if (code == JAILHOUSE_HC_DISABLE && regs[0] == 0)
- arch_shutdown_self(this_cpu_data());
- }
+ if (code == JAILHOUSE_HC_DISABLE && regs[0] == 0)
+ arch_shutdown_self(this_cpu_data());

return TRAP_HANDLED;
}
--
2.1.4

Jan Kiszka

unread,
Sep 30, 2016, 3:21:05 AM9/30/16
to Jailhouse, Antonios Motakis
I just found this in the AArch64 patches:

"On AArch64 PSCI calls can be issued via SVC64 hypercalls as well,
contrary to AArch32 which uses SVC32 calls only."

What makes that arch different von 32-bit? In both cases, the root cell
only has a primitive hypervisor stub installed prior to enabling
Jailhouse, and that stub does not handle PSCI hypercalls.

Looking at linux/drivers/firmware/psci.c seems to confirm this: it's
shared by both archs.

Jan

--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

Mark Rutland

unread,
Sep 30, 2016, 12:20:04 PM9/30/16
to Jan Kiszka, Jailhouse, Antonios Motakis
Hi Jan,

On Fri, Sep 30, 2016 at 09:21:03AM +0200, Jan Kiszka wrote:
> I just found this in the AArch64 patches:
>
> "On AArch64 PSCI calls can be issued via SVC64 hypercalls as well,
> contrary to AArch32 which uses SVC32 calls only."

I take it s/SVC32/SMC32/ ?

It's worth noting that this only applies to *some* PSCI calls; more details
below.

> What makes that arch different von 32-bit?

SMC32 calls can only take/return 32-bit quantities, and SMC64 calls can
take/return 64-bit quantities. Per the SMC Calling Convention, SMC64 calls are
*only* valid when taken from AArch64. SMC32 calls are valid from both AArch32
and AArch64.

Some PSCI calls (e.g. CPU_ON) have both SMC32/SMC64 variants because they must
take/return a 64-bit value on AArch64 (e.g. entry point address for CPU_ON).

Some PSCI calls (e.g. CPU_OFF) are *always* SMC32, as they deal entirely in
32-bit quantities (and/or take no arguments), and it doesn't make sense to have
another ID for the exact same function prototype and logic.

For more details, see ARM DEN 0028A ("SMC CALLING CONVENTION") and ARM DEN
0022C ("POWER STATE COORDINATION INTERFACE (PSCI)").

> In both cases, the root cell only has a primitive hypervisor stub installed
> prior to enabling Jailhouse, and that stub does not handle PSCI hypercalls.
>
> Looking at linux/drivers/firmware/psci.c seems to confirm this: it's
> shared by both archs.

The driver is common. SMC32-only calls are called directly, while for
SMC32/SMC64 functions, we figure out the ID and calling convention per the
architecture the driver is built for. The PSCI_FN_NATIVE() macro handles this
difference.

Does that help to clarify things?

Thanks,
Mark.

Jan Kiszka

unread,
Oct 1, 2016, 2:57:10 AM10/1/16
to Mark Rutland, Jailhouse, Antonios Motakis
Yeah, kind of. I was actually looking for and reading something else
when I stumbled over "hypercall" in that comment: If AArch64 has a
strict need for *HVC* based PSCI. This commit here removed it for
AArch32, and I'm already did the same for the AArch64 rebased series I'm
working on. I still see no reason to have HVC PSCI dispatch in
Jailhouse, no matter if it's AArch32 or 64.

Jan

Mark Rutland

unread,
Oct 3, 2016, 6:57:58 AM10/3/16
to Jan Kiszka, Jailhouse, Antonios Motakis
On Sat, Oct 01, 2016 at 08:57:05AM +0200, Jan Kiszka wrote:
> I was actually looking for and reading something else when I stumbled
> over "hypercall" in that comment: If AArch64 has a strict need for
> *HVC* based PSCI.

Yes, in some cases. On platforms without the security extensions, HVC
must be used, as SMC is undefined and cannot be trapped at any higher
exception level.

Given this, I would expect software at EL2/Hyp to only handle HVC from
lower exception levels, as this consistently works even when SMC is
undefined.

Does that help at all?

Thanks,
Mark.

Jan Kiszka

unread,
Oct 3, 2016, 1:04:45 PM10/3/16
to Mark Rutland, Jailhouse, Antonios Motakis
Well, I still don't see how we could support PSCI + Jailhouse on
platforms without EL3 (if the PSCI code is forced into EL2, there is no
room for Jailhouse anymore). So I do not see why Jailhouse should react
on HVC for PSCI purposes. Hence, I removed that code also for arm64.

Thanks,
Jan
Reply all
Reply to author
Forward
0 new messages