[PATCH] arm: Reject unknown SMC invocations

2 views
Skip to first unread message

Jan Kiszka

unread,
Sep 21, 2016, 1:47:16 AM9/21/16
to Jailhouse
Reject every SMC requests except for the emulated PSCI services. This is
required because we have generally no idea about what services are
behind an interface, and even the calling convention is undefined.
Better fail loudly and then resolve the valid cases on a per-platform
basis.

This obsoletes the smc stub in exception.S, so remove it.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/arm/exception.S | 6 ------
hypervisor/arch/arm/traps.c | 8 ++++----
2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/hypervisor/arch/arm/exception.S b/hypervisor/arch/arm/exception.S
index 4ae57c7..90c580f 100644
--- a/hypervisor/arch/arm/exception.S
+++ b/hypervisor/arch/arm/exception.S
@@ -79,9 +79,3 @@ vmreturn:
hvc:
hvc #0
bx lr
-
- .arch_extension sec
- .globl smc
-smc:
- smc #0
- bx lr
diff --git a/hypervisor/arch/arm/traps.c b/hypervisor/arch/arm/traps.c
index 4b2cd21..0b522e2 100644
--- a/hypervisor/arch/arm/traps.c
+++ b/hypervisor/arch/arm/traps.c
@@ -249,10 +249,10 @@ static int arch_handle_smc(struct trap_context *ctx)
{
unsigned long *regs = ctx->regs;

- if (IS_PSCI_32(regs[0]) || IS_PSCI_UBOOT(regs[0]))
- regs[0] = psci_dispatch(ctx);
- else
- regs[0] = smc(regs[0], regs[1], regs[2], regs[3]);
+ if (!IS_PSCI_32(regs[0]) && !IS_PSCI_UBOOT(regs[0]))
+ return TRAP_FORBIDDEN;
+
+ regs[0] = psci_dispatch(ctx);

arch_skip_instruction(ctx);

--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
Reply all
Reply to author
Forward
0 new messages