All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls
@ 2017-01-30 17:21 Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 1/6] xen/arm: traps: Reorder early overwrite of FID Edgar E. Iglesias
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-30 17:21 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

The ZynqMP software stack has an extensive Firmware API.
Software at EL1 is increasingly dependant on this API. In fact,
a large set of use-cases for Linux already require access
to firmware. In a couple of months, we expect that most setups
will need it, so this is becoming somewhat urgent.

Services provided by the API, among other things include:
* Clock Management
* PHY Configuration
* Power Management
* FPGA configuration
* etc

Adding support for accessing firmware comes in two steps.

1. Allow the hw domain (dom0) to call into firmware. This enables
   all devices to work with PV setups.

2. Allow other guests to use the Firmware API. This will be needed
   to fully support Device pass-through.
   We cannot give un-supervised access to unprivileged guests, so
   the idea is to mediate these calls in Xen or preferably in
   dom0. Mediation mainly consists of ref-counting and filtering.

This RFC patch series implements step #1.

There are quite a few options on how to implement step #2, e.g:
1. Trap HVC/SMC calls from unpriv guests and handle them in dom0.
   This could be done in a user-space agent.
2. Add a PV protocol carrying these calls. This is similar to #1.
3. Add several generic PV protocols carrying a set of platform independent
   generic calls that get translated or mapped to firmware calls
   in dom0. E.g PV-Clock, PV-Power, PV-FPGA.
4. Others??

A benefit with #1 is that we could support unmodified bare-metal
guests. Such guests would continue to issue SMC calls from EL1 just as
if they were running without a hypervisor.

Best regards,
Edgar

Edgar E. Iglesias (6):
  xen/arm: traps: Reorder early overwrite of FID
  xen/arm: Introduce platform_hvc
  xen/arm: Allow platform_hvc to handle guest SMC calls
  xen/arm: Introduce call_smcc64
  xen/arm: zynqmp: Forward plaform specific firmware calls
  xen/arm: zynqmp: Remove blacklist of ZynqMP's PM node

 xen/arch/arm/platform.c                |  8 ++++
 xen/arch/arm/platforms/xilinx-zynqmp.c | 67 +++++++++++++++++++++++++++++++---
 xen/arch/arm/traps.c                   | 13 ++++++-
 xen/include/asm-arm/platform.h         |  5 +++
 xen/include/asm-arm/processor.h        | 40 ++++++++++++++++++++
 5 files changed, 125 insertions(+), 8 deletions(-)

-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [RFC v1 1/6] xen/arm: traps: Reorder early overwrite of FID
  2017-01-30 17:21 [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls Edgar E. Iglesias
@ 2017-01-30 17:21 ` Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 2/6] xen/arm: Introduce platform_hvc Edgar E. Iglesias
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-30 17:21 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Move the early setting of PSCI_RESULT_REG to a later stage
avoiding the early override of the FID that's stored in
the same register.

No functional change.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/traps.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 35d8e8b..a5fbf1e 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1334,8 +1334,6 @@ static void do_trap_psci(struct cpu_user_regs *regs)
 {
     register_t fid = PSCI_ARG(regs,0);
 
-    /* preloading in case psci_mode_check fails */
-    PSCI_RESULT_REG(regs) = PSCI_INVALID_PARAMETERS;
     switch( fid )
     {
     case PSCI_cpu_off:
@@ -1368,6 +1366,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
     case PSCI_0_2_FN_MIGRATE_INFO_UP_CPU:
     case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU:
         perfc_incr(vpsci_migrate_info_up_cpu);
+        PSCI_RESULT_REG(regs) = PSCI_INVALID_PARAMETERS;
         if ( psci_mode_check(current->domain, fid) )
             PSCI_RESULT_REG(regs) = do_psci_0_2_migrate_info_up_cpu();
         break;
@@ -1384,6 +1383,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
     case PSCI_0_2_FN_CPU_ON:
     case PSCI_0_2_FN64_CPU_ON:
         perfc_incr(vpsci_cpu_on);
+        PSCI_RESULT_REG(regs) = PSCI_INVALID_PARAMETERS;
         if ( psci_mode_check(current->domain, fid) )
         {
             register_t vcpuid = PSCI_ARG(regs,1);
@@ -1396,6 +1396,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
     case PSCI_0_2_FN_CPU_SUSPEND:
     case PSCI_0_2_FN64_CPU_SUSPEND:
         perfc_incr(vpsci_cpu_suspend);
+        PSCI_RESULT_REG(regs) = PSCI_INVALID_PARAMETERS;
         if ( psci_mode_check(current->domain, fid) )
         {
             uint32_t pstate = PSCI_ARG32(regs,1);
@@ -1408,6 +1409,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
     case PSCI_0_2_FN_AFFINITY_INFO:
     case PSCI_0_2_FN64_AFFINITY_INFO:
         perfc_incr(vpsci_cpu_affinity_info);
+        PSCI_RESULT_REG(regs) = PSCI_INVALID_PARAMETERS;
         if ( psci_mode_check(current->domain, fid) )
         {
             register_t taff = PSCI_ARG(regs,1);
@@ -1419,6 +1421,7 @@ static void do_trap_psci(struct cpu_user_regs *regs)
     case PSCI_0_2_FN_MIGRATE:
     case PSCI_0_2_FN64_MIGRATE:
         perfc_incr(vpsci_cpu_migrate);
+        PSCI_RESULT_REG(regs) = PSCI_INVALID_PARAMETERS;
         if ( psci_mode_check(current->domain, fid) )
         {
             uint32_t tcpu = PSCI_ARG32(regs,1);
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [RFC v1 2/6] xen/arm: Introduce platform_hvc
  2017-01-30 17:21 [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 1/6] xen/arm: traps: Reorder early overwrite of FID Edgar E. Iglesias
@ 2017-01-30 17:21 ` Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 3/6] xen/arm: Allow platform_hvc to handle guest SMC calls Edgar E. Iglesias
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-30 17:21 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Introduce platform_hvc as a way to handle hypercalls that
Xen does not know about in a platform specific way. This
is particularly useful for implementing the SiP (SoC
implementation specific) service calls.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/platform.c        | 8 ++++++++
 xen/arch/arm/traps.c           | 3 +++
 xen/include/asm-arm/platform.h | 5 +++++
 3 files changed, 16 insertions(+)

diff --git a/xen/arch/arm/platform.c b/xen/arch/arm/platform.c
index 0af6d57..90ea6b8 100644
--- a/xen/arch/arm/platform.c
+++ b/xen/arch/arm/platform.c
@@ -127,6 +127,14 @@ void platform_poweroff(void)
         platform->poweroff();
 }
 
+bool platform_hvc(struct cpu_user_regs *regs)
+{
+    if ( platform && platform->hvc )
+        return platform->hvc(regs);
+
+    return false;
+}
+
 bool_t platform_has_quirk(uint32_t quirk)
 {
     uint32_t quirks = 0;
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index a5fbf1e..e8cd111 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -43,6 +43,7 @@
 #include <asm/cpufeature.h>
 #include <asm/flushtlb.h>
 #include <asm/monitor.h>
+#include <asm/platform.h>
 
 #include "decode.h"
 #include "vtimer.h"
@@ -1429,6 +1430,8 @@ static void do_trap_psci(struct cpu_user_regs *regs)
         }
         break;
     default:
+        if ( platform_hvc(regs) )
+                return;
         domain_crash_synchronous();
         return;
     }
diff --git a/xen/include/asm-arm/platform.h b/xen/include/asm-arm/platform.h
index 08010ba..4d51f0a 100644
--- a/xen/include/asm-arm/platform.h
+++ b/xen/include/asm-arm/platform.h
@@ -26,6 +26,10 @@ struct platform_desc {
     void (*reset)(void);
     /* Platform power-off */
     void (*poweroff)(void);
+    /* Platform specific HVC handler.
+     * Returns true if the call was handled and false if not.
+     */
+    bool (*hvc)(struct cpu_user_regs *regs);
     /*
      * Platform quirks
      * Defined has a function because a platform can support multiple
@@ -55,6 +59,7 @@ int platform_cpu_up(int cpu);
 #endif
 void platform_reset(void);
 void platform_poweroff(void);
+bool platform_hvc(struct cpu_user_regs *regs);
 bool_t platform_has_quirk(uint32_t quirk);
 bool_t platform_device_is_blacklisted(const struct dt_device_node *node);
 
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [RFC v1 3/6] xen/arm: Allow platform_hvc to handle guest SMC calls
  2017-01-30 17:21 [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 1/6] xen/arm: traps: Reorder early overwrite of FID Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 2/6] xen/arm: Introduce platform_hvc Edgar E. Iglesias
@ 2017-01-30 17:21 ` Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 4/6] xen/arm: Introduce call_smcc64 Edgar E. Iglesias
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-30 17:21 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Allow platform_hvc to handle guest SMC calls (as well as
HVC calls) in a platform specific way.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/traps.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index e8cd111..1925122 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -2622,6 +2622,9 @@ static void do_trap_smc(struct cpu_user_regs *regs, const union hsr hsr)
     if ( current->domain->arch.monitor.privileged_call_enabled )
         rc = monitor_smc();
 
+    if ( platform_hvc(regs) )
+        rc = 1;
+
     if ( rc != 1 )
         inject_undef_exception(regs, hsr);
 }
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [RFC v1 4/6] xen/arm: Introduce call_smcc64
  2017-01-30 17:21 [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls Edgar E. Iglesias
                   ` (2 preceding siblings ...)
  2017-01-30 17:21 ` [RFC v1 3/6] xen/arm: Allow platform_hvc to handle guest SMC calls Edgar E. Iglesias
@ 2017-01-30 17:21 ` Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 5/6] xen/arm: zynqmp: Forward plaform specific firmware calls Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 6/6] xen/arm: zynqmp: Remove blacklist of ZynqMP's PM node Edgar E. Iglesias
  5 siblings, 0 replies; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-30 17:21 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Introduce call_smcc64, a helper function to issue 64-bit SMC
calls that follow the SMC Calling Convention. This includes
returning up to 4 64-bit values.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/include/asm-arm/processor.h | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
index afc0e9a..a604f8c 100644
--- a/xen/include/asm-arm/processor.h
+++ b/xen/include/asm-arm/processor.h
@@ -706,6 +706,46 @@ void vcpu_regs_user_to_hyp(struct vcpu *vcpu,
 int call_smc(register_t function_id, register_t arg0, register_t arg1,
              register_t arg2);
 
+/*
+ * Helper to issue a 64-bit SMC according to the SMC Calling Convention.
+ *
+ * @fid:      Function Identifier
+ * @a0 - a5:  6 arguments
+ * @ret:      Pointer to 4 register_t carrying return values
+ */
+static inline register_t call_smcc64(register_t fid,
+                                     register_t a0,
+                                     register_t a1,
+                                     register_t a2,
+                                     register_t a3,
+                                     register_t a4,
+                                     register_t a5,
+                                     register_t *ret)
+{
+    register register_t x0 asm("x0") = fid;
+    register register_t x1 asm("x1") = a0;
+    register register_t x2 asm("x2") = a1;
+    register register_t x3 asm("x3") = a2;
+    register register_t x4 asm("x4") = a3;
+    register register_t x5 asm("x5") = a4;
+    register register_t x6 asm("x6") = a5;
+
+    asm volatile ("smc #0\n"
+                  : "+r" (x0), "+r" (x1), "+r" (x2), "+r" (x3),
+                    "+r" (x4), "+r" (x5), "+r" (x6)
+                  :
+                  : "x7", "x8", "x9", "x10", "x11", "x12",
+                    "x13", "x14", "x15", "x16", "x17" );
+
+    if (ret) {
+        ret[0] = x0;
+        ret[1] = x1;
+        ret[2] = x2;
+        ret[3] = x3;
+    }
+    return x0;
+}
+
 void do_trap_guest_error(struct cpu_user_regs *regs);
 
 #endif /* __ASSEMBLY__ */
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [RFC v1 5/6] xen/arm: zynqmp: Forward plaform specific firmware calls
  2017-01-30 17:21 [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls Edgar E. Iglesias
                   ` (3 preceding siblings ...)
  2017-01-30 17:21 ` [RFC v1 4/6] xen/arm: Introduce call_smcc64 Edgar E. Iglesias
@ 2017-01-30 17:21 ` Edgar E. Iglesias
  2017-01-31  9:52   ` Edgar E. Iglesias
  2017-01-30 17:21 ` [RFC v1 6/6] xen/arm: zynqmp: Remove blacklist of ZynqMP's PM node Edgar E. Iglesias
  5 siblings, 1 reply; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-30 17:21 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Forward platform specific firmware calls from the hardware
domain to firmware.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/platforms/xilinx-zynqmp.c | 63 ++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c b/xen/arch/arm/platforms/xilinx-zynqmp.c
index 2adee91..bde7f52 100644
--- a/xen/arch/arm/platforms/xilinx-zynqmp.c
+++ b/xen/arch/arm/platforms/xilinx-zynqmp.c
@@ -19,6 +19,46 @@
 
 #include <asm/platform.h>
 
+/* Service calls.  */
+#define SVC_MASK             0x3F000000
+#define SVC_SIP              0x02000000    /* SoC Implementation Specific.  */
+
+/* SMC function IDs for SiP Service queries */
+#define ZYNQMP_SIP_SVC_CALL_COUNT       0xff00
+#define ZYNQMP_SIP_SVC_UID              0xff01
+#define ZYNQMP_SIP_SVC_VERSION          0xff03
+
+enum pm_api_id {
+    /* Miscellaneous API functions: */
+    GET_API_VERSION = 1,
+    SET_CONFIGURATION,
+    GET_NODE_STATUS,
+    GET_OPERATING_CHARACTERISTIC,
+    REGISTER_NOTIFIER,
+    /* API for suspending of PUs: */
+    REQUEST_SUSPEND,
+    SELF_SUSPEND,
+    FORCE_POWERDOWN,
+    ABORT_SUSPEND,
+    REQUEST_WAKEUP,
+    SET_WAKEUP_SOURCE,
+    SYSTEM_SHUTDOWN,
+    /* API for managing PM slaves: */
+    REQUEST_NODE,
+    RELEASE_NODE,
+    SET_REQUIREMENT,
+    SET_MAX_LATENCY,
+    /* Direct control API functions: */
+    RESET_ASSERT,
+    RESET_GET_STATUS,
+    MMIO_WRITE,
+    MMIO_READ,
+    PM_INIT,
+    FPGA_LOAD,
+    FPGA_GET_STATUS,
+    GET_CHIPID,
+};
+
 static const char * const zynqmp_dt_compat[] __initconst =
 {
     "xlnx,zynqmp",
@@ -32,8 +72,31 @@ static const struct dt_device_match zynqmp_blacklist_dev[] __initconst =
     { /* sentinel */ },
 };
 
+bool zynqmp_hvc(struct cpu_user_regs *regs)
+{
+    uint32_t fid = regs->x0;
+    uint32_t svc = fid & SVC_MASK;
+    register_t ret[4];
+
+    /* We only forward SiP service calls from the hw domain to firmware.  */
+    if ( svc != SVC_SIP || !is_hardware_domain(current->domain) )
+        return false;
+
+    /* Forward the call.  */
+    call_smcc64(regs->x0, regs->x1, regs->x2, regs->x3,
+                regs->x4, regs->x5, regs->x6, ret);
+
+    /* Transfer return values into guest registers.  */
+    regs->x0 = ret[0];
+    regs->x1 = ret[1];
+    regs->x2 = ret[2];
+    regs->x3 = ret[3];
+    return true;
+}
+
 PLATFORM_START(xgene_storm, "Xilinx ZynqMP")
     .compatible = zynqmp_dt_compat,
+    .hvc = zynqmp_hvc,
     .blacklist_dev = zynqmp_blacklist_dev,
 PLATFORM_END
 
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [RFC v1 6/6] xen/arm: zynqmp: Remove blacklist of ZynqMP's PM node
  2017-01-30 17:21 [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls Edgar E. Iglesias
                   ` (4 preceding siblings ...)
  2017-01-30 17:21 ` [RFC v1 5/6] xen/arm: zynqmp: Forward plaform specific firmware calls Edgar E. Iglesias
@ 2017-01-30 17:21 ` Edgar E. Iglesias
  5 siblings, 0 replies; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-30 17:21 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Stop blacklisting ZynqMP's power management node.
This is now possible since we allow the hardware domain to
issue HVC/SMC calls to firmware.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/platforms/xilinx-zynqmp.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c b/xen/arch/arm/platforms/xilinx-zynqmp.c
index bde7f52..d21bd87 100644
--- a/xen/arch/arm/platforms/xilinx-zynqmp.c
+++ b/xen/arch/arm/platforms/xilinx-zynqmp.c
@@ -65,13 +65,6 @@ static const char * const zynqmp_dt_compat[] __initconst =
     NULL
 };
 
-static const struct dt_device_match zynqmp_blacklist_dev[] __initconst =
-{
-    /* Power management is not yet supported.  */
-    DT_MATCH_COMPATIBLE("xlnx,zynqmp-pm"),
-    { /* sentinel */ },
-};
-
 bool zynqmp_hvc(struct cpu_user_regs *regs)
 {
     uint32_t fid = regs->x0;
@@ -97,7 +90,6 @@ bool zynqmp_hvc(struct cpu_user_regs *regs)
 PLATFORM_START(xgene_storm, "Xilinx ZynqMP")
     .compatible = zynqmp_dt_compat,
     .hvc = zynqmp_hvc,
-    .blacklist_dev = zynqmp_blacklist_dev,
 PLATFORM_END
 
 /*
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [RFC v1 5/6] xen/arm: zynqmp: Forward plaform specific firmware calls
  2017-01-30 17:21 ` [RFC v1 5/6] xen/arm: zynqmp: Forward plaform specific firmware calls Edgar E. Iglesias
@ 2017-01-31  9:52   ` Edgar E. Iglesias
  0 siblings, 0 replies; 8+ messages in thread
From: Edgar E. Iglesias @ 2017-01-31  9:52 UTC (permalink / raw)
  To: Edgar E. Iglesias; +Cc: julien.grall, sstabellini, xen-devel

On Mon, Jan 30, 2017 at 06:21:54PM +0100, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> 
> Forward platform specific firmware calls from the hardware
> domain to firmware.
> 
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> ---
>  xen/arch/arm/platforms/xilinx-zynqmp.c | 63 ++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
> 
> diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c b/xen/arch/arm/platforms/xilinx-zynqmp.c
> index 2adee91..bde7f52 100644
> --- a/xen/arch/arm/platforms/xilinx-zynqmp.c
> +++ b/xen/arch/arm/platforms/xilinx-zynqmp.c
> @@ -19,6 +19,46 @@
>  
>  #include <asm/platform.h>
>  
> +/* Service calls.  */
> +#define SVC_MASK             0x3F000000
> +#define SVC_SIP              0x02000000    /* SoC Implementation Specific.  */
> +
> +/* SMC function IDs for SiP Service queries */
> +#define ZYNQMP_SIP_SVC_CALL_COUNT       0xff00
> +#define ZYNQMP_SIP_SVC_UID              0xff01
> +#define ZYNQMP_SIP_SVC_VERSION          0xff03
> +
> +enum pm_api_id {
> +    /* Miscellaneous API functions: */
> +    GET_API_VERSION = 1,
> +    SET_CONFIGURATION,

These pm_api_id enums are a left over and not needed, I'll remove them from
future versions of this patch.

Cheers,
Edgar


> +    GET_NODE_STATUS,
> +    GET_OPERATING_CHARACTERISTIC,
> +    REGISTER_NOTIFIER,
> +    /* API for suspending of PUs: */
> +    REQUEST_SUSPEND,
> +    SELF_SUSPEND,
> +    FORCE_POWERDOWN,
> +    ABORT_SUSPEND,
> +    REQUEST_WAKEUP,
> +    SET_WAKEUP_SOURCE,
> +    SYSTEM_SHUTDOWN,
> +    /* API for managing PM slaves: */
> +    REQUEST_NODE,
> +    RELEASE_NODE,
> +    SET_REQUIREMENT,
> +    SET_MAX_LATENCY,
> +    /* Direct control API functions: */
> +    RESET_ASSERT,
> +    RESET_GET_STATUS,
> +    MMIO_WRITE,
> +    MMIO_READ,
> +    PM_INIT,
> +    FPGA_LOAD,
> +    FPGA_GET_STATUS,
> +    GET_CHIPID,
> +};
> +
>  static const char * const zynqmp_dt_compat[] __initconst =
>  {
>      "xlnx,zynqmp",
> @@ -32,8 +72,31 @@ static const struct dt_device_match zynqmp_blacklist_dev[] __initconst =
>      { /* sentinel */ },
>  };
>  
> +bool zynqmp_hvc(struct cpu_user_regs *regs)
> +{
> +    uint32_t fid = regs->x0;
> +    uint32_t svc = fid & SVC_MASK;
> +    register_t ret[4];
> +
> +    /* We only forward SiP service calls from the hw domain to firmware.  */
> +    if ( svc != SVC_SIP || !is_hardware_domain(current->domain) )
> +        return false;
> +
> +    /* Forward the call.  */
> +    call_smcc64(regs->x0, regs->x1, regs->x2, regs->x3,
> +                regs->x4, regs->x5, regs->x6, ret);
> +
> +    /* Transfer return values into guest registers.  */
> +    regs->x0 = ret[0];
> +    regs->x1 = ret[1];
> +    regs->x2 = ret[2];
> +    regs->x3 = ret[3];
> +    return true;
> +}
> +
>  PLATFORM_START(xgene_storm, "Xilinx ZynqMP")
>      .compatible = zynqmp_dt_compat,
> +    .hvc = zynqmp_hvc,
>      .blacklist_dev = zynqmp_blacklist_dev,
>  PLATFORM_END
>  
> -- 
> 2.7.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-01-31  9:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-30 17:21 [RFC v1 0/6] zynqmp: Add forwarding of platform specific firmware calls Edgar E. Iglesias
2017-01-30 17:21 ` [RFC v1 1/6] xen/arm: traps: Reorder early overwrite of FID Edgar E. Iglesias
2017-01-30 17:21 ` [RFC v1 2/6] xen/arm: Introduce platform_hvc Edgar E. Iglesias
2017-01-30 17:21 ` [RFC v1 3/6] xen/arm: Allow platform_hvc to handle guest SMC calls Edgar E. Iglesias
2017-01-30 17:21 ` [RFC v1 4/6] xen/arm: Introduce call_smcc64 Edgar E. Iglesias
2017-01-30 17:21 ` [RFC v1 5/6] xen/arm: zynqmp: Forward plaform specific firmware calls Edgar E. Iglesias
2017-01-31  9:52   ` Edgar E. Iglesias
2017-01-30 17:21 ` [RFC v1 6/6] xen/arm: zynqmp: Remove blacklist of ZynqMP's PM node Edgar E. Iglesias

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.