[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 05/11] xsm: refactor xsm_ops handling


  • To: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 6 Sep 2021 19:31:06 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=UygBNLCUMU/3ZqHyK+ayd1mRTwySTUAf+mwn1mECLiE=; b=CSSVsWFQk6N3WwQGZemL4ItwcNOfTYDoPBsq8CK/wiArGQ9xZP85j7XN1QHeo+JkN5TdfVJFE3CWkiBRpNMYPRrH4c8uD9GkLJMpeQmPhNw1E3Rl/rz4pukuXXjfeoIwYbsxHBDB1I/oHfk1z2k2+j3xzHXtPHv0g+8GHLfBqotOlX35tVMVBb8ZwYb714m6TwFJsnr4MGT8Lid0oVVf5GnTX/h/zv4UCO6vvORQoG4yoCNiSz8HdN1bE8ZRWtsFkCEqtckbcNeF4MWWvqn4zsPtM464XYs/1ViQEvSboW7OCbLAAL/3G0JOxIesbcIncyMP9gbxeGSrfkNqsZSsFQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwa9ylUfSuABZrSS4VpoSNl8yzUqMZFvQLdcnji+e7Z4yYxOTjomuz+gLD8XwjBZUYFLlw6DCM49OWNf7IeIciCrNG7H0YAGHM/5leksFZ4FtmzTiO+ChYA0gRty1tZODKDjcNIHC/LAe9HiqfTxrfnK4EH8ReqSJf0oVurJCDWHRPh9CxPyuvChpZhc74MtAN/RDSQfJPS09HKncGBHM6JXK867EOWFzH3YjwouQKM/5klr66W4+QSKnqVYDmy5Kkv1ETusf7IZJJpJLt07PF0DFFLOL+weG+TRZCE78CM087X5gPgYUdXALNHXsDp7LFbouVccxicmtARACx4Cbw==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
  • Delivery-date: Mon, 06 Sep 2021 18:31:22 +0000
  • Ironport-hdrordr: A9a23:6q6oeaMOWHKamMBcT1P155DYdb4zR+YMi2TDiHoedfUFSKOlfp 6V8MjztSWVtN4QMEtQ/exoS5PwP080kqQFnrX5XI3SIDUO3VHIEGgM1/qY/9SNIVyZygcZ79 YcT0EcMqyCMbEZt7eD3ODQKb9Jq7PrgcPY55at854ud3AMV0gJ1XYINu/xKDwOeOApP+tdKH PR3Ls8m9L2Ek5nH/hTS0N1E9TrlpnurtbLcBQGDxko5E2nii6p0qfzF1y90g0FWz1C7L8++S yd+jaJqJmLgrWe8FvxxmXT55NZlJ/IzcZCPtWFjowwJi/3ggilSYx9U/mpvSwzosuo9FE2+e O87CsIDoBW0Tf8b2u1qRzi103J1ysv0WbrzRuijX7qsaXCNXkHIvsEobgcXgrS6kImst05+r lMxXilu51eCg6FtDjh5vDTPisa1XackD4Hq6o+nnZfWYwRZPt6tooE5n5YF58GAWbT9J0nKu 9zF8vRjcwmMW9yV0qp+1WH/ebcGkjaRny9Mw8/U42uonlrdUlCvgklLJd1pAZHyHo/I6M0r9 gsfJ4YzY2mdfVmGZ6VMt1xCPdfOla9NC4kD1jiVmgPNJt3cU4l+KSHrYnc2omRCeo1Jd0J6c z8bG8=
  • Ironport-sdr: f3l083uFU2Pk3PCfh8bZTRZZkEJr1TAghVd2Qds3PcS9aZydkc7hSGIgAfpN+ADcCypXcj6BzB hAFqmkCxg+NWgJaNECHrLiMa2Yy/0EMjzNBd6GAaC9MRXj2HNy9yudc7rXhg3T969k+REy6lCF e0T2PFBG8pDXi38jy3PKWfUftAj6P7em3DY8Bc2nDC9D3Zp85FZjrTIDS23BOHOfweNz/0mY6m 3XvGqfZ+V+xUIiwoM93KMMN88RlcZrnf65ryGZiN9gyErKQLkIE8iGYsEoE2hX/rHq3D114UaS CdXmpda65LNNHIyBLcJK3QBY
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03/09/2021 20:06, Daniel P. Smith wrote:
> This renames the `struct xsm_operations` to the shorter `struct xsm_ops` and
> converts the global xsm_ops from being a pointer to an explicit instance. As
> part of this conversion, it reworks the XSM modules init function to return
> their xsm_ops struct which is copied in to the global xsm_ops instance.
>
> Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>

Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

However, some suggestions...

> diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c
> index 55483292c5..859af3fe9a 100644
> --- a/xen/xsm/xsm_core.c
> +++ b/xen/xsm/xsm_core.c
> @@ -28,9 +28,17 @@
>  #include <asm/setup.h>
>  #endif
>  
> -#define XSM_FRAMEWORK_VERSION    "1.0.0"
> +#define XSM_FRAMEWORK_VERSION    "1.0.1"
>  
> -struct xsm_operations *xsm_ops;
> +struct xsm_ops __read_mostly xsm_ops;
> +
> +enum xsm_ops_state {
> +    XSM_OPS_UNREGISTERED,
> +    XSM_OPS_REG_FAILED,
> +    XSM_OPS_REGISTERED,
> +};
> +
> +static enum xsm_ops_state xsm_ops_registered = XSM_OPS_UNREGISTERED;

__read_mostly, or can this be __initdata ?

> @@ -87,25 +88,35 @@ static int __init xsm_core_init(const void 
> *policy_buffer, size_t policy_size)
>      }
>  #endif
>  
> -    if ( verify(&dummy_xsm_ops) )
> +    if ( xsm_ops_registered != XSM_OPS_UNREGISTERED )
>      {
> -        printk(XENLOG_ERR "Could not verify dummy_xsm_ops structure\n");
> +        printk(XENLOG_ERR
> +               "Could not init XSM, xsm_ops register already attempted\n");
>          return -EIO;
>      }
>  
> -    xsm_ops = &dummy_xsm_ops;
> -
>      switch ( xsm_bootparam )
>      {
>      case XSM_BOOTPARAM_DUMMY:
> +        xsm_ops_registered = XSM_OPS_REGISTERED;
>          break;
>  
>      case XSM_BOOTPARAM_FLASK:
> -        flask_init(policy_buffer, policy_size);
> +        ops = flask_init(policy_buffer, policy_size);
> +        if ( ops )
> +        {
> +            xsm_ops_registered = XSM_OPS_REGISTERED;
> +            xsm_ops = *ops;
> +        }
>          break;
>  
>      case XSM_BOOTPARAM_SILO:
> -        silo_init();
> +        ops = silo_init();
> +        if ( ops )
> +        {
> +            xsm_ops_registered = XSM_OPS_REGISTERED;
> +            xsm_ops = *ops;
> +        }

This if ( ops ) block can be deduplicated by moving after the switch()
statement.  It's going to be common to all everything except dummy.

~Andrew




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.