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

Re: [PATCH v4 2/3] x86/platform: introduce XENPF_get_ucode_revision


  • To: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 5 Apr 2023 10:56:02 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+mVTO62r6MdNDfQvzJjVKCOtuW5R5PdZ4og7pljUhPc=; b=nePbIZtD0nvR9bshlTd/7uTXv3D+YWMQA2oSa++ZYDq5m/RC/qWsAF7Ov0RvYiodAVMIH3w+nriT/1BeB2mAdKXt3C2DrvKK+fiyfE7RC+m5RTcpuBt6baUT7xSxL+veujQFfC7G+DWNW4Ldqr3WgsW30ka2dd7ly1/c3Zu96B08Ng+RfnehbcXgMZadJyTH69Jf7+yEs0ZewD4O5Z590piZC6oJKiZhNtgl1zz3sbUsLp0lgWQvj3y8GuG3AKunNGp+t4iHqhBdfHT9XzUeqC4xOUJfybeoyVD27Aa/PN8gB9umj6FtbYg4nWTqQkyxNuVJZJsJaKBAyxt+dbEAOw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XBPb2bwqdMtAV18nOX5hsDz40W/yqZhYRFJnVJL6SKT9F+JmEVz0Rq1kJjIRrVBle6Bc+yxeOesadtg7HhUnVWlI9EJ6PCoX16Es/rkLLHSD3uU7vYN5z4xhp1Vf7N7vseHU73JOLcG8zwSRqahb3fz09aCasGndx/2FAz9o1YAOnynPw04h+5orRf9qVzP/dVgJJv2aQPw263DgPPhWooA8GWEUdQBZxrypgZQ5mX0Ccf5j3nBh04S1807O3ZTrp/JVWUKsROo/AHi965NmciNJXWKw0daJX1I6QB1pBBvcBjdwGsJtl+0eyau4UWq15SUdgPI9YjU1ulfdatuzLg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 05 Apr 2023 08:56:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 04.04.2023 18:06, Sergey Dyasli wrote:
> Currently it's impossible to get CPU's microcode revision from Xen after
> late loading without looking into Xen logs which is not always convenient.
> 
> Add a new platform op in order to get the required data from Xen and
> provide a wrapper for libxenctrl.
> 
> Signed-off-by: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
with two remarks:

> --- a/tools/libs/ctrl/xc_misc.c
> +++ b/tools/libs/ctrl/xc_misc.c
> @@ -243,6 +243,24 @@ int xc_get_cpu_version(xc_interface *xch, struct 
> xenpf_pcpu_version *cpu_ver)
>      return 0;
>  }
>  
> +int xc_get_ucode_revision(xc_interface *xch,
> +                          struct xenpf_ucode_revision *ucode_rev)
> +{
> +    int ret;
> +    struct xen_platform_op op = {
> +        .cmd = XENPF_get_ucode_revision,
> +        .u.ucode_revision.cpu = ucode_rev->cpu,
> +    };
> +
> +    ret = do_platform_op(xch, &op);
> +    if ( ret != 0 )
> +        return ret;

Is there anything wrong with omitting this if() and ...

> +    *ucode_rev = op.u.ucode_revision;
> +
> +    return 0;

... using "return ret" here?

> --- a/xen/arch/x86/platform_hypercall.c
> +++ b/xen/arch/x86/platform_hypercall.c
> @@ -640,6 +640,35 @@ ret_t do_platform_op(
>      }
>      break;
>  
> +    case XENPF_get_ucode_revision:
> +    {
> +        struct xenpf_ucode_revision *rev = &op->u.ucode_revision;
> +
> +        if ( !get_cpu_maps() )
> +        {
> +            ret = -EBUSY;
> +            break;
> +        }
> +
> +        /* TODO: make it possible to know ucode revisions for parked CPUs */
> +        if ( (rev->cpu >= nr_cpu_ids) || !cpu_online(rev->cpu) )
> +            ret = -ENOENT;

While the cpu_online() check needs to be done under lock, it's kind of
misleading for the caller to tell it to try again later when it has
passed an out-of-range CPU number.

Jan



 


Rackspace

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