From: Chao Liu <[email protected]>

Guests use the SMCCC version call to select the conduit for firmware
services such as SCMI.  QEMU reports PSCI 1.1 but rejects the SMCCC
version call, so a guest running with the SMC PSCI conduit never
initializes SMCCC and cannot use SCMI over SMC.

Advertise SMCCC 1.1 through PSCI_FEATURES and the SMCCC version call.

Signed-off-by: Chao Liu <[email protected]>
Signed-off-by: Yifan Wang <[email protected]>
---
 target/arm/kvm-consts.h |  5 +++++
 target/arm/tcg/psci.c   | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h
index 9fba3e886d..ab64c91888 100644
--- a/target/arm/kvm-consts.h
+++ b/target/arm/kvm-consts.h
@@ -88,6 +88,11 @@ MISMATCH_CHECK(QEMU_PSCI_0_2_FN64_CPU_ON, 
PSCI_0_2_FN64_CPU_ON);
 MISMATCH_CHECK(QEMU_PSCI_0_2_FN64_MIGRATE, PSCI_0_2_FN64_MIGRATE);
 MISMATCH_CHECK(QEMU_PSCI_1_0_FN_PSCI_FEATURES, PSCI_1_0_FN_PSCI_FEATURES);
 
+/* SMCCC architecture calls. */
+#define QEMU_SMCCC_VERSION_FUNC_ID                0x80000000
+#define QEMU_SMCCC_ARCH_FEATURES_FUNC_ID          0x80000001
+#define QEMU_SMCCC_VERSION_1_1                     QEMU_PSCI_VERSION_1_1
+
 /* PSCI v0.2 return values used by TCG emulation of PSCI */
 
 /* No Trusted OS migration to worry about when offlining CPUs */
diff --git a/target/arm/tcg/psci.c b/target/arm/tcg/psci.c
index d8e01df762..81ca2fbb44 100644
--- a/target/arm/tcg/psci.c
+++ b/target/arm/tcg/psci.c
@@ -95,6 +95,20 @@ void arm_handle_psci_call(ARMCPU *cpu)
     case QEMU_PSCI_0_2_FN_PSCI_VERSION:
         ret = QEMU_PSCI_VERSION_1_1;
         break;
+    case QEMU_SMCCC_VERSION_FUNC_ID:
+        ret = QEMU_SMCCC_VERSION_1_1;
+        break;
+    case QEMU_SMCCC_ARCH_FEATURES_FUNC_ID:
+        switch ((uint32_t)param[1]) {
+        case QEMU_SMCCC_VERSION_FUNC_ID:
+        case QEMU_SMCCC_ARCH_FEATURES_FUNC_ID:
+            ret = 0;
+            break;
+        default:
+            ret = QEMU_PSCI_RET_NOT_SUPPORTED;
+            break;
+        }
+        break;
     case QEMU_PSCI_0_2_FN_MIGRATE_INFO_TYPE:
         ret = QEMU_PSCI_0_2_RET_TOS_MIGRATION_NOT_REQUIRED; /* No trusted OS */
         break;
@@ -177,6 +191,7 @@ void arm_handle_psci_call(ARMCPU *cpu)
     case QEMU_PSCI_1_0_FN_PSCI_FEATURES:
         switch (param[1]) {
         case QEMU_PSCI_0_2_FN_PSCI_VERSION:
+        case QEMU_SMCCC_VERSION_FUNC_ID:
         case QEMU_PSCI_0_2_FN_MIGRATE_INFO_TYPE:
         case QEMU_PSCI_0_2_FN_AFFINITY_INFO:
         case QEMU_PSCI_0_2_FN64_AFFINITY_INFO:
-- 
2.53.0


Reply via email to