From: "Jan Beulich" Subject: Re: [PATCH for Xen 4.5] xen/arm: Add support for GICv3 for domU Date: Fri, 31 Oct 2014 09:02:12 +0000 Message-ID: <54535E240200007800043DAC@mail.emea.novell.com> References: <1414695092-20761-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xk861-0003ne-Il for xen-devel@lists.xenproject.org; Fri, 31 Oct 2014 09:02:13 +0000 In-Reply-To: <1414695092-20761-1-git-send-email-julien.grall@linaro.org> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: ian.campbell@citrix.com, tim@xen.org, Vijaya Kumar K , Ian Jackson , stefano.stabellini@citrix.com, xen-devel@lists.xenproject.org, Daniel De Graaf List-Id: xen-devel@lists.xenproject.org >>> On 30.10.14 at 19:51, wrote: > + case XEN_DOMCTL_configure_domain: > + { > + uint8_t gic_version; > + > + /* > + * Xen 4.5: The vGIC is emulating the same version of the > + * hardware GIC. Only the value XEN_DOMCTL_CONFIG_GIC_DEFAULT > + * is allowed. The DOMCTL will return the actual version of the > + * GIC. > + */ > + if ( domctl->u.configuredomain.gic_version != XEN_DOMCTL_CONFIG_GIC_DEFAULT ) > + return -EINVAL; > + > + switch ( gic_hw_version() ) > + { > + case GIC_V3: > + gic_version = XEN_DOMCTL_CONFIG_GIC_V3; > + break; > + case GIC_V2: > + gic_version = XEN_DOMCTL_CONFIG_GIC_V2; > + break; > + default: > + BUG(); > + } > + > + domctl->u.configuredomain.gic_version = gic_version; > + > + /* TODO: Make the copy generic for all ARCH domctl */ > + if ( __copy_to_guest(u_domctl, domctl, 1) ) With just a single field needing copying, __copy_field_to_guest() would be quite a bit more efficient. > --- a/xen/include/public/domctl.h > +++ b/xen/include/public/domctl.h > @@ -68,6 +68,19 @@ struct xen_domctl_createdomain { > typedef struct xen_domctl_createdomain xen_domctl_createdomain_t; > DEFINE_XEN_GUEST_HANDLE(xen_domctl_createdomain_t); > > +#if defined(__arm__) || defined(__aarch64__) > +#define XEN_DOMCTL_CONFIG_GIC_DEFAULT 0 > +#define XEN_DOMCTL_CONFIG_GIC_V2 1 > +#define XEN_DOMCTL_CONFIG_GIC_V3 2 > +/* XEN_DOMCTL_configure_domain */ > +struct xen_domctl_configuredomain { The naming suggests that the #if really should be around just the gic_version field (with a dummy field in the #else case to be C89 compatible, e.g. a zero width unnamed bitfield) and the corresponding #define-s above, ... > + /* IN/OUT parameters */ > + uint8_t gic_version; > +}; > +typedef struct xen_domctl_configuredomain xen_domctl_configuredomain_t; > +DEFINE_XEN_GUEST_HANDLE(xen_domctl_configuredomain_t); > +#endif > + > /* XEN_DOMCTL_getdomaininfo */ > struct xen_domctl_getdomaininfo { > /* OUT variables. */ > @@ -1056,6 +1069,7 @@ struct xen_domctl { > #define XEN_DOMCTL_set_vcpu_msrs 73 > #define XEN_DOMCTL_setvnumainfo 74 > #define XEN_DOMCTL_psr_cmt_op 75 > +#define XEN_DOMCTL_configure_domain 76 > #define XEN_DOMCTL_gdbsx_guestmemio 1000 > #define XEN_DOMCTL_gdbsx_pausevcpu 1001 > #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 > @@ -1064,6 +1078,9 @@ struct xen_domctl { > domid_t domain; > union { > struct xen_domctl_createdomain createdomain; > +#if defined(__arm__) || defined(__aarch64__) > + struct xen_domctl_configuredomain configuredomain; > +#endif ... making this conditional unnecessary. Alternatively the name would perhaps better be changed to include ARM in some way. Jan