clear-pkgs-linux-iot-lts2018/0934-check-return-value-of-...

43 lines
1.2 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Zhang, Qi" <qi1.zhang@intel.com>
Date: Thu, 16 Aug 2018 18:04:44 +0800
Subject: [PATCH] check return value of hypercall
exit from probe if acrn does not enable trusty
Change-Id: I99271cd96c6df46e141b4e57a2af378119a1c25c
Tracked-On: OAM-67637
Signed-off-by: Zhang, Qi <qi1.zhang@intel.com>
---
drivers/trusty/trusty.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/trusty/trusty.c b/drivers/trusty/trusty.c
2020-10-27 02:14:06 +08:00
index f37a1a58dce8..881924f88e4f 100755
--- a/drivers/trusty/trusty.c
+++ b/drivers/trusty/trusty.c
@@ -72,13 +72,18 @@ static inline ulong smc_evmm(ulong r0, ulong r1, ulong r2, ulong r3)
static inline ulong smc_acrn(ulong r0, ulong r1, ulong r2, ulong r3)
{
register unsigned long smc_id asm("r8") = ACRN_HC_SWITCH_WORLD;
+ register signed long ret asm("rax");
__asm__ __volatile__(
"vmcall; \n"
- : "=D"(r0)
+ : "=D"(r0), "=r"(ret)
: "r"(smc_id), "D"(r0), "S"(r1), "d"(r2), "b"(r3)
- : "rax"
);
+ if(ret < 0) {
+ pr_err("trusty: %s: hypercall failed: %ld\n", __func__, ret);
+ r0 = (ulong)SM_ERR_NOT_SUPPORTED;
+ }
+
return r0;
}
--
https://clearlinux.org