diff mbox series

[Xen-devel,03/10] xen/arm: vpl011: Enable pl011 emulation for a guest domain in Xen

Message ID 1491212673-13476-4-git-send-email-bhupinder.thakur@linaro.org
State New
Headers show
Series pl011 emulation support in Xen | expand

Commit Message

Bhupinder Thakur April 3, 2017, 9:44 a.m. UTC
Vpl011 emulation is enabled for a guest domain in Xen only when it is
enabled through an option in libxl provided by the user through
guest configuration.

The pl011 enable/disable knob in libxl is introduced in the following
patch:
xen/arm: vpl011: Provide a knob in libxl to enable/disable pl011
emulation

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
 xen/arch/arm/domain.c       | 11 +++++++++++
 xen/common/domctl.c         |  3 +++
 xen/include/public/domctl.h |  2 ++
 xen/include/xen/sched.h     |  4 ++++
 4 files changed, 20 insertions(+)

Comments

Stefano Stabellini April 19, 2017, 12:27 a.m. UTC | #1
On Mon, 3 Apr 2017, Bhupinder Thakur wrote:
> Vpl011 emulation is enabled for a guest domain in Xen only when it is
> enabled through an option in libxl provided by the user through
> guest configuration.
> 
> The pl011 enable/disable knob in libxl is introduced in the following
> patch:
> xen/arm: vpl011: Provide a knob in libxl to enable/disable pl011
> emulation
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
>  xen/arch/arm/domain.c       | 11 +++++++++++
>  xen/common/domctl.c         |  3 +++
>  xen/include/public/domctl.h |  2 ++
>  xen/include/xen/sched.h     |  4 ++++
>  4 files changed, 20 insertions(+)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 7e43691..8e383d0 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -36,6 +36,9 @@
>  #include <asm/platform.h>
>  #include "vtimer.h"
>  #include "vuart.h"
> +#ifdef CONFIG_VPL011_CONSOLE
> +#include <xen/vpl011.h>
> +#endif
>  
>  DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
>  
> @@ -626,6 +629,11 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
>      if ( (rc = domain_vtimer_init(d, config)) != 0 )
>          goto fail;
>  
> +    if ( domcr_flags & DOMCRF_vconsole )
> +#ifdef CONFIG_VPL011_CONSOLE
> +        if ( (rc = domain_vpl011_init(d, config)) != 0 )
> +#endif
> +            goto fail;

Ideally, the #ifdef CONFIG_VPL011_CONSOLE would be confined within
xen/vpl011.h, and #ifndef CONFIG_VPL011_CONSOLE:

static inline int domain_vpl011_init(struct domain *d, ...) { return -ENOSYS; }


>      update_domain_wallclock_time(d);
>  
>      /*
> @@ -660,6 +668,9 @@ fail:
>  
>  void arch_domain_destroy(struct domain *d)
>  {
> +#ifdef CONFIG_VPL011_CONSOLE
> +    domain_vpl011_deinit(d);
> +#endif

Same here, in vpl011.h:

static inline void domain_vpl011_deinit(struct domain *d) { }


>      /* IOMMU page table is shared with P2M, always call
>       * iommu_domain_destroy() before p2m_teardown().
>       */
> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
> index 12cf4a9..3385479 100644
> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -506,6 +506,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>                 | XEN_DOMCTL_CDF_hap
>                 | XEN_DOMCTL_CDF_s3_integrity
>                 | XEN_DOMCTL_CDF_oos_off
> +               | XEN_DOMCTL_VCONSOLE_enable
>                 | XEN_DOMCTL_CDF_xs_domain)) )
>              break;
>  
> @@ -550,6 +551,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>              domcr_flags |= DOMCRF_oos_off;
>          if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_xs_domain )
>              domcr_flags |= DOMCRF_xs_domain;
> +        if ( op->u.createdomain.flags & XEN_DOMCTL_VCONSOLE_enable )
> +            domcr_flags |= DOMCRF_vconsole;
>  
>          d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref,
>                            &op->u.createdomain.config);
> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
> index 85cbb7c..1fca180 100644
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -66,6 +66,8 @@ struct xen_domctl_createdomain {
>   /* Is this a xenstore domain? */
>  #define _XEN_DOMCTL_CDF_xs_domain     5
>  #define XEN_DOMCTL_CDF_xs_domain      (1U<<_XEN_DOMCTL_CDF_xs_domain)
> +#define _XEN_DOMCTL_VCONSOLE_enable      6
> +#define XEN_DOMCTL_VCONSOLE_enable       (1U<<_XEN_DOMCTL_VCONSOLE_enable)
>      uint32_t flags;
>      struct xen_arch_domainconfig config;
>  };
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 063efe6..4efdc48 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -555,6 +555,10 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags,
>  #define _DOMCRF_xs_domain       6
>  #define DOMCRF_xs_domain        (1U<<_DOMCRF_xs_domain)
>  
> + /* DOMCRF_vconsole: enable virtual console emulation. Used for aarach64. */

typo: aarch64


> +#define _DOMCRF_vconsole  7
> +#define DOMCRF_vconsole   (1U<<_DOMCRF_vconsole)
> +
>  /*
>   * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
>   * This is the preferred function if the returned domain reference
> -- 
> 2.7.4
>
diff mbox series

Patch

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 7e43691..8e383d0 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -36,6 +36,9 @@ 
 #include <asm/platform.h>
 #include "vtimer.h"
 #include "vuart.h"
+#ifdef CONFIG_VPL011_CONSOLE
+#include <xen/vpl011.h>
+#endif
 
 DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
 
@@ -626,6 +629,11 @@  int arch_domain_create(struct domain *d, unsigned int domcr_flags,
     if ( (rc = domain_vtimer_init(d, config)) != 0 )
         goto fail;
 
+    if ( domcr_flags & DOMCRF_vconsole )
+#ifdef CONFIG_VPL011_CONSOLE
+        if ( (rc = domain_vpl011_init(d, config)) != 0 )
+#endif
+            goto fail;
     update_domain_wallclock_time(d);
 
     /*
@@ -660,6 +668,9 @@  fail:
 
 void arch_domain_destroy(struct domain *d)
 {
+#ifdef CONFIG_VPL011_CONSOLE
+    domain_vpl011_deinit(d);
+#endif
     /* IOMMU page table is shared with P2M, always call
      * iommu_domain_destroy() before p2m_teardown().
      */
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 12cf4a9..3385479 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -506,6 +506,7 @@  long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
                | XEN_DOMCTL_CDF_hap
                | XEN_DOMCTL_CDF_s3_integrity
                | XEN_DOMCTL_CDF_oos_off
+               | XEN_DOMCTL_VCONSOLE_enable
                | XEN_DOMCTL_CDF_xs_domain)) )
             break;
 
@@ -550,6 +551,8 @@  long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
             domcr_flags |= DOMCRF_oos_off;
         if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_xs_domain )
             domcr_flags |= DOMCRF_xs_domain;
+        if ( op->u.createdomain.flags & XEN_DOMCTL_VCONSOLE_enable )
+            domcr_flags |= DOMCRF_vconsole;
 
         d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref,
                           &op->u.createdomain.config);
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 85cbb7c..1fca180 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -66,6 +66,8 @@  struct xen_domctl_createdomain {
  /* Is this a xenstore domain? */
 #define _XEN_DOMCTL_CDF_xs_domain     5
 #define XEN_DOMCTL_CDF_xs_domain      (1U<<_XEN_DOMCTL_CDF_xs_domain)
+#define _XEN_DOMCTL_VCONSOLE_enable      6
+#define XEN_DOMCTL_VCONSOLE_enable       (1U<<_XEN_DOMCTL_VCONSOLE_enable)
     uint32_t flags;
     struct xen_arch_domainconfig config;
 };
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 063efe6..4efdc48 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -555,6 +555,10 @@  struct domain *domain_create(domid_t domid, unsigned int domcr_flags,
 #define _DOMCRF_xs_domain       6
 #define DOMCRF_xs_domain        (1U<<_DOMCRF_xs_domain)
 
+ /* DOMCRF_vconsole: enable virtual console emulation. Used for aarach64. */
+#define _DOMCRF_vconsole  7
+#define DOMCRF_vconsole   (1U<<_DOMCRF_vconsole)
+
 /*
  * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
  * This is the preferred function if the returned domain reference