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

Re: [PATCH v3 2/3] x86/platform: introduce XENPF_get_ucode_version


  • To: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 21 Mar 2023 13:07:02 +0000
  • 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E1q5RwVhqWVRc9D7jH/SZU5ZE68C1KdZ5LX16hTcv50=; b=Ok7V1SIhe1z4zlg45HgyLGadGcVme/M0aRY2w+VvCs5+4ksQYtn7C2nWxjWUwH8Z1S04Uazb1W2CBMP315ROlmJS8rfoRFf/WV98x4EVNL68PCIA0oID+YVpZ8Ew+5t4iBjQlkkqKU0gTk/g1n1UrCrt79EefmMPMkvSoE6Sz1UK8NgVd1Vkw19JmFz9aD1hwap9gnMXdRNO7vrvHTUq9iqDzpQ9lIpHQhKMxAJ/Yd9z8CLZ86YQZIxcQVpSgpiWcUrL/DtT3/IvioYMM0p28Yp2Rbf2YbZSnwLR+Q6qG2D2cRzLeCF6bWhcsHtMdrc+lQPUgJg+HqVBvA1juIrC1g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcxF3/RQCeL7OtEjuAmKf1+m5BXkzE6av17jdHI17rXKZszQIDPD4gpHtIvEX9XZOVggjHKVwD/+XmDDPo/G8qN+49DyD/X7L6F24eYCLInZwQfx8dDxA7WHA4OpfUYHhsWjmnlmWboxOBk2ddqB/uE5x3dxrrz9oRSFayqjRe4eKr/RRsgEQII9wqMYgcctjiaU8JNw2ze7CrkBeu9uMFGWU5k1X93UXrW16YbwVpZeIu66ODGm2ecRFzEwf+099aOLyb+DdupmHAp2+mwv27jXn9BLOPUhu0qhJRJJ8akX3DXnm791lWf0uLN4b5E5a7379rQFsUFlLcU+IPEr1Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, 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>
  • Delivery-date: Tue, 21 Mar 2023 13:07:31 +0000
  • Ironport-data: A9a23:B50XH6p0M24lrBtqlsx+o5oiIIBeBmL8ZBIvgKrLsJaIsI4StFCzt garIBmGOq2NYWume4x/bo6/oEpV6MeGyoNkTgo9qis2RSoT+ZuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06WNwUmAWP6gR5weFzSBNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXABQkXxfTnb3o+a+ERM82oMYKFfXRGLpK7xmMzRmBZRonabbqZvyToPN9gnI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeeraYWIEjCJbZw9ckKwj 2TK5WnmRDodM8SS02Gt+XOwnO7f2yj8Xer+EZXhrqQz2QPOnjV75Bs+XFq6+vKyiEqHddMCM EAb4REeo/Jo3Rn+JjX6d1jiyJKehTYMVtwVH+Ak5QWlzqvP/x3fFmUCViRGatEtqIkxXzNC/ l2Dks7tBDdvmKaIUn/b/bCRxRutPQAFIGlEYjULJSMH7MPku5oblQ/UQ5BoF6vdpt/oHTD9x RiaoS54gK8c5eYQzLmy913DhzOqp7DKQxQz6wGRWXiqhj6Vf6agbo2srFTes/BJKd/ASkHb5 SdZ3c+D8OoJEJeB0jSXR/kAF62o4PDDNyDAhVloHN8q8DHFF2OfQL28KQpWfC9BWvvosxewC KMPkWu9PKNuAUY=
  • Ironport-hdrordr: A9a23:cgYRb6pvjGXiGye56cHfl9saV5okeYIsimQD101hICG9Evbzqy nIpoV/6faUskdyZJhOo7y90cW7Lk80lqQFgrX5X43CYOCOggLBQb2KhbGI/9SKIU3DH4Bmu5 uJccJFebnN5VsRt7ec3DWF
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21/03/2023 11:47 am, Sergey Dyasli wrote:
> Currently it's impossible to get CPU's microcode revision after late
> loading without looking into Xen logs which is not always convenient.

It's not impossible (you can do `modprobe msr; rdmsr 0x8b`), but it is
inconvenient for library code.

>
> 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>
> ---
>  tools/include/xenctrl.h                  |  2 ++
>  tools/libs/ctrl/xc_misc.c                | 21 +++++++++++++++++
>  xen/arch/x86/platform_hypercall.c        | 30 ++++++++++++++++++++++++
>  xen/arch/x86/x86_64/platform_hypercall.c |  4 ++++
>  xen/include/public/platform.h            | 12 ++++++++++
>  xen/include/xlat.lst                     |  1 +
>  6 files changed, 70 insertions(+)
>
> diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
> index 8aa747dc2e..d3ef7a48a5 100644
> --- a/tools/include/xenctrl.h
> +++ b/tools/include/xenctrl.h
> @@ -1187,6 +1187,8 @@ int xc_cputopoinfo(xc_interface *xch, unsigned 
> *max_cpus,
>                     xc_cputopo_t *cputopo);
>  int xc_microcode_update(xc_interface *xch, const void *buf, size_t len);
>  int xc_get_cpu_version(xc_interface *xch, struct xenpf_pcpu_version 
> *cpu_ver);
> +int xc_get_ucode_version(xc_interface *xch,
> +                         struct xenpf_ucode_version *ucode_ver);

Throughout, we should use "revision" rather than "version" as that is
the terminology used by both Intel and AMD.

>  int xc_numainfo(xc_interface *xch, unsigned *max_nodes,
>                  xc_meminfo_t *meminfo, uint32_t *distance);
>  int xc_pcitopoinfo(xc_interface *xch, unsigned num_devs,
> diff --git a/tools/libs/ctrl/xc_misc.c b/tools/libs/ctrl/xc_misc.c
> index f2f6e4348e..b93477d189 100644
> --- a/tools/libs/ctrl/xc_misc.c
> +++ b/tools/libs/ctrl/xc_misc.c
> @@ -246,6 +246,27 @@ int xc_get_cpu_version(xc_interface *xch, struct 
> xenpf_pcpu_version *cpu_ver)
>      return 0;
>  }
>  
> +int xc_get_ucode_version(xc_interface *xch,
> +                         struct xenpf_ucode_version *ucode_ver)
> +{
> +    int ret;
> +    DECLARE_PLATFORM_OP;
> +
> +    if ( !xch || !ucode_ver )
> +        return -1;
> +
> +    platform_op.cmd = XENPF_get_ucode_version;
> +    platform_op.u.ucode_version.xen_cpuid = ucode_ver->xen_cpuid;

Same notes as per patch 1.

> diff --git a/xen/include/public/platform.h b/xen/include/public/platform.h
> index 60caa5ce7e..232df79d5f 100644
> --- a/xen/include/public/platform.h
> +++ b/xen/include/public/platform.h
> @@ -614,6 +614,17 @@ DEFINE_XEN_GUEST_HANDLE(xenpf_symdata_t);
>  typedef struct dom0_vga_console_info xenpf_dom0_console_t;
>  DEFINE_XEN_GUEST_HANDLE(xenpf_dom0_console_t);
>  
> +#define XENPF_get_ucode_version 65
> +struct xenpf_ucode_version {
> +    uint32_t xen_cpuid;       /* IN:  CPU number to get the revision from.  
> */

We commonly call this just "cpu".  As a platform op pertaining to
microcode, it cannot plausibly be confused with vcpus.

> +    uint32_t cpu_signature;   /* OUT: CPU signature (CPUID.1.EAX).          
> */

The cpu_ prefix can be dropped, as can ...

> +    uint32_t pf;              /* OUT: Processor Flags.                      
> */
> +                              /*      Only applicable to Intel.             
> */
> +    uint32_t ucode_revision;  /* OUT: Microcode Revision.                   
> */

the ucode_ prefix here.

I'm tempted to say that I'm happy to fix all of this on commit as it's
all mechanical changes.

~Andrew



 


Rackspace

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