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

Re: [PATCH v4 3/3] tools/xen-ucode: print information about currently loaded ucode


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 6 Apr 2023 00:48:33 +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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b89C+WDjoBzAWdyAvIeyTESJkKHIuxXpo6ReecPT/Co=; b=FhL62pFx0ntXoHWKMozas0V4YJ4ys4y3SUDNKNAM93vYurt+h4D2Gb3xjeQNdq3n9lk/IjLLfki+wkeMfDJMo8I3cdG/Lmpii2VI5IkFSWWi3jgPKHELW59qynoC5WxFrBAEu5EzDUJAUf0M/JtZAy/DzjoXwuHrWmH1TdQLAjravwWpEA7J8GAkvzUDCzyvINVSOXxAd/NCIbXI5wNodsxgpDDwSa6MMWFx+34xQ3ErMEanl9Ex11rTAfLmT3wxDgPQxPiZnn6fIBT0vCQSHpwIk3bYKYlfjE1bWdbwouBdQosNouXG9jzD8FzEwT5I+hX83oTPVkHWg2gph7dAqw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PJMDTH+pScY8ERFsFjI7qubxn3OCYpihgBKYD7h9l4etFodi0kVnECdtGZjfmTNv0Q45xi152wlqTfBq2hW//uDuXvkEVvxd0qlbZT1tmBlTOaSalifS6KZ/sn1ofq3cHseWEZykbc6aE1FH0dNCdu4Eo1o1lGloxNBYslwR7YP0Y/zraSym2dgbxXv1mTCWPseUZ/c/hKIscGn51KhVmCRAII4/EvLTXtMGri4B1w6CZe9UOP74Xe2dIqzsCRfNII15f1LDNR/fwASA7ISg1jwGxTRy9jG/lLsGYLeDSLcMbBszJ+A9+MCrng9oEJmbiWSIV9pda1IIjLq02nnPow==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: 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 23:49:05 +0000
  • Ironport-data: A9a23:lMjACK8UAA6F4CNyZlG1DrUDZH+TJUtcMsCJ2f8bNWPcYEJGY0x3m DAWUT+OP6mPYDPxf48nPYTipxwF65Pcx9FnTQI9+Sk8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kI/1BjOkGlA5AdmOagW5AS2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkli3 906dREBZCnZ2cCpg6iSd9s1ussaeZyD0IM34hmMzBn/JNN/GNXoZPyP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWNilUuidABM/KMEjCObexTklyVu STt+GPhDwtBHNee1SCE4jSngeqncSbTAdpOT+zorK4z6LGV7nMuMh0cbna2mPOauFOYQIpUO VZX9BN7+MDe82TuFLERRSaQonSJoxodUNp4CPAh5UeGza+8yxmdLngJSHhGctNOnM05Xzsxz XeSgsjkQzdotdW9S2+Z97qShSO/P24SN2BqTTQfUQIP7t3noYcyphHCVNBuFOiylNKdMSH9x XWGoTYzg50XjNUXzOOr8FbfmTWuq5PVCAkv6W3qsnmN6wp4YMuuYNWu4F2CtPJYdt/GFx+Go WQOnNWY4KYWF5aRmSeRQeILWra0+/KCNz6aillqd3U8ywmQF7eYVdg4yFlDyI1Ba67opReBj JfvhD5s
  • Ironport-hdrordr: A9a23:63rR6qta9seN7xaHytvvsmQf7skDVdV00zEX/kB9WHVpm7+j5r yTdZUgpGTJYVMqMk3I9urwXpVoLUmslqKdpLNhWYtKPzOWwFdATrsSlLcKqgeIc0afygce79 YET0EXMrzN5DNB/KHHCXyDYqsdKbe8gcKVbCTlo0uFjzsGV0it1WhE436gYzdLrcB9a6YEKA ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05/04/2023 10:11 am, Jan Beulich wrote:
> On 04.04.2023 18:06, Sergey Dyasli wrote:
>> Add an option to xen-ucode tool to print the currently loaded ucode
>> revision and also print it during usage info.  Print CPU signature and
>> platform flags as well.  The raw data comes from XENPF_get_cpu_version
>> and XENPF_get_ucode_revision platform ops.
>>
>> Example output:
>>     Intel:
>>     CPU signature 06-55-04 (raw 0x00050654) pf 0x1 revision 0x02006e05
>>
>>     AMD:
>>     CPU signature fam19h (raw 0x00a00f11) revision 0x0a0011ce
> Wouldn't it make sense to also report the model number here, even if
> ucode blob file names (currently) don't include it?

I have debated FF-MM-SS on AMD several times.

AMD do document all their CPUs consistently in hex, and I know the model
tables alarmingly well now.  Furthermore, it's not a straight nibble
shuffle from the raw value.

So yeah, it probably is worth including.  Given that we're not guessing
the Linux path of the microcode, it can replace the fam19h without any
loss of information.

> While for the revision always printing 8 digits is definitely helpful, I
> wonder whether the two top nibbles of the raw value wouldn't better be
> omitted. (I understand Andrew did ask for this, but it's unclear to me
> why he extended this request to the raw fields.)

For precisely the same reason.  (With a question like this, you clearly
don't work frequently with microcode crossing a wide range of CPUs...)

>> --- a/tools/misc/xen-ucode.c
>> +++ b/tools/misc/xen-ucode.c
>> @@ -12,22 +12,89 @@
>>  #include <fcntl.h>
>>  #include <xenctrl.h>
>>  
>> +static xc_interface *xch;
>> +
>> +static const char intel_id[] = "GenuineIntel";
>> +static const char   amd_id[] = "AuthenticAMD";
>> +
>> +static void show_curr_cpu(FILE *f)
>> +{
>> +    int ret;
>> +    struct xenpf_pcpu_version cpu_ver = { .xen_cpuid = 0 };
>> +    struct xenpf_ucode_revision ucode_rev = { .cpu = 0 };
> As mentioned before - the current state of the system may be
> inconsistent, so I question the entire lack of a way to know of
> this by using this tool (even if via a specific command line
> option, defaulting to CPU0-only).

It's a theoretical problem, not a practical one, and definitely not
something worthy to block this patch with.

Software always has more up-to-date microcode than firmware these days,
and it has probably been a decade since there was a system released
which could usefully function with asymmetric microcode.

I know we seen it in the past, but only on truly ancient systems.

>> +    ret = xc_get_cpu_version(xch, &cpu_ver);
>> +    if ( ret )
>> +    {
>> +        fprintf(f, "Failed to get CPU information. (err: %s)\n",
>> +                strerror(errno));
>> +        exit(1);

Use err(), which removes all the boilerplate here.

>> +    }
>> +    else if ( memcmp(cpu_ver.vendor_id, amd_id,
>> +                     sizeof(cpu_ver.vendor_id)) == 0 )
>> +    {
>> +        fprintf(f, "CPU signature fam%xh (raw 0x%08x) revision 0x%08x\n",
>> +                   cpu_ver.family, ucode_rev.signature, ucode_rev.revision);
>> +    }
>> +    else
>> +    {
>> +        fprintf(f, "Unsupported CPU vendor: %s\n", cpu_ver.vendor_id);
>> +        exit(3);
>> +    }
>> +}
>> +
>>  int main(int argc, char *argv[])
>>  {
>>      int fd, ret;
>>      char *filename, *buf;
>>      size_t len;
>>      struct stat st;
>> -    xc_interface *xch;
>> +
>> +    xch = xc_interface_open(NULL, NULL, 0);
>> +    if ( xch == NULL )
>> +    {
>> +        fprintf(stderr, "Error opening xc interface. (err: %s)\n",
>> +                strerror(errno));
>> +        exit(1);
>> +    }
>>  
>>      if ( argc < 2 )
>>      {
>> -        fprintf(stderr,
>> -                "xen-ucode: Xen microcode updating tool\n"
>> -                "Usage: %s <microcode blob>\n", argv[0]);
>> +        fprintf(stderr, "xen-ucode: Xen microcode updating tool\n");
>> +        show_curr_cpu(stderr);
> I recall you had it this way before, but I don't see why this information
> needs to be part of argument error handling.

Because it is specifically useful information to be given when running
xen-ucode with no arguments.

But also because this patch predates Spectre/Meltdown going public, and
is documented this way for XenServer.

That said, the information does need correcting because it's changed to be:

  "Usage: %s [show-cpu-info | <microcode file>]"

in this patch.  (and file is specifically more relevant than calling it
a blob).

~Andrew



 


Rackspace

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