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

Re: [for-4.18][PATCH 1/2] xen/x86: Add family guards to the is_zen[12]_uarch() macros


  • To: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 13 Oct 2023 13:36:02 +0200
  • 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=b8Mkb1dxJSxWyiRyjTHtU5xXSWm8UuOAXHZy9DWqhnM=; b=D/6JoH82Zi0NBNM7Li3xTZVBoewJ/hrPvlqUxDO+co1m27CxrdOZgrAqvBc77DfzHOoUz23z+tZ+IKZiCCMoC1PGQ65C/QsWOu8eKqdTUh2NKaFrEATdbSkm9YapPiVInghW21IQIlm5pnQ7Y3Wit7DbG7Ck4Xv74Ps5be7Nw5hfUZmXpZbMnNAfEsOxfaveSTKqSDgD67pb0qy/DF/bVqPmSr5MLO3Jr9TZrOnDS6LPRdvUlP+Jko0HomkRDsgGrcDkDQgsRESagAMqvQ1WHeKPWxxaYoqC1oI8H5o6Fx+IW/iPZLRdKdUt9f4bixLx+FoBxVGj2vGzgtKg2Da6pA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y+Wr53o8djTvUjdanVrjXlnu9hQE+I6zvyqty3Vq+UNgvKEQ7Mc2RnIDJZWd1JXSL8B/s1dLd+t8ek0h7aA9RlTvAArfxZWhNPW9TmNcQTBQdOOOSlD2LtCiqAAhd3kOqgssnMv73QQPZTjtDk+DOuQpse7mDTCFoPGu/1QTYEepPzw4Pyb+N01Z2GhEzTw+Xg3ZLHAtu5frZFxZh8vfEbUFRAYuD6jIcd93wTbL6bpkAyoIVzQozcS2z+v0JapDqisA9CRNNtBW84sawkPsHh6GHYiwYZEppospdzhCYOb4gIW1kFqdfQfgdlRvGX4MbRLr/77zi7SouU9nd4HQIQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Fri, 13 Oct 2023 11:36:32 +0000
  • Ironport-data: A9a23:3qaXqqubm0ifhaRvzQGA8d1rfufnVIdfMUV32f8akzHdYApBsoF/q tZmKTrTPq3ZNGP2fYtzbo+39RgEu5KGx4dqHgBqqi80HisU+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVaicfHg3HFc4IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4rKq41v0gnRkPaoQ5QeHzCFPZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwdg89RD2b2dmMya+7ddhAquk5cOPUM9ZK0p1g5Wmx4fcOZ7nmGvyPzvgBmTA6i4ZJAOrUY NcfZXx3dhPcbhZTO1ARTpUjgOOvgXq5eDpdwL6XjfNvvy6Pk0osjv60bou9lt+iHK25mm6Co W3L5SLhCwwyP92D0zuVtHmrg4cjmAuiAtJISO3nr6QCbFu7/VRLEBAte0CHgcawqmfkZ9d0B Xwqw397xUQ13AnxJjXnZDWxpHOGtxgQQd0WDeQ+7AyPzYLf5wGECi4PSTspQMwrsoo6SCIn0 neNnsj1Hnp/vbuNU3Wf+7yI6zSoNkA9L2UPeCsFRgst+MT4rcc4iRenZslnOL64iJvyAz6Y6 xCHqjIvwYoai8Ej3r++u1vAhlqRSoPhSwc04kDcWTuj5wYgPYq9PdX2uB7c8OpKK5ufQh+Zp n8YlsOC7ecIS5aQiCiKR+ZLF7asjxqYDADhbZdUN8FJ31yQF7SLJOi8PBkWyJ9VD/s5
  • Ironport-hdrordr: A9a23:gA+brKGoIY7cso8VpLqEi8eALOsnbusQ8zAXPiFKKSC9F/byqy nAppkmPHPP4gr5O0tApTn/Asa9qBrnnPZICOIqUYtKMjOJhFeV
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Oct 13, 2023 at 12:23:43PM +0100, Alejandro Vallejo wrote:
> Hi,
> 
> I'll just remove this patch (and amend the next) in the interest of having
> it committed early. That said...
> 
> On Fri, Oct 13, 2023 at 10:14:45AM +0800, Andrew Cooper wrote:
> > On 13/10/2023 1:26 am, Alejandro Vallejo wrote:
> > > It slightly simplifies the code that uses them at no real cost because the
> > > code is very rarely executed. This makes it harder to confuse zen uarches
> > > due to missing or mistaken family checks.
> > 
> > I'm afraid I disagree.
> As it stands, it's a matter of time before a bug of this form creeps up. 
> Particularly
> because it reads very innocent.
> 
>    if (is_zen1_uarch())
>       fun1();
>    else if (is_zen2_uarch())
>       fun2();
>    else if (is_zen3_uarch())
>       fun3();
>    else if (is_zen4_uarch())
>       fun4();
> 
> Particularly if the bodies of each conditional are big enough that you lose
> track of the family you're dealing with.
> 
> > 
> > It's bogus to do a family check without a vendor check.
> I can get behind that. I didn't include the vendor check because by and
> large these macros are used in vendor-specific areas. Would that appease
> your concerns? Whenever the macros are used we're in glacially cold paths
> anyway.
> 
> > By making this
> > change, you're separating (spatially in code, and therefore cognitively)
> > the two checks that it's important to be able to cross-check.
> IMO, It's no different from separating the heuristic from the vendor/family
> check. What causes definite cognitive load is (as a reader) having to
> remember what particular fields must be read off boot_cpu_data in order to
> discriminate zenN, which of them are co-familiar and so on.
> 
> > 
> > > diff --git a/xen/arch/x86/include/asm/amd.h 
> > > b/xen/arch/x86/include/asm/amd.h
> > > index d862cb7972..5a40bcc2ba 100644
> > > --- a/xen/arch/x86/include/asm/amd.h
> > > +++ b/xen/arch/x86/include/asm/amd.h
> > > @@ -145,11 +145,12 @@
> > >   * Hygon (Fam18h) but without simple model number rules.  Instead, use 
> > > STIBP
> > >   * as a heuristic that distinguishes the two.
> > >   *
> > > - * The caller is required to perform the appropriate vendor/family checks
> > > - * first.
> > > + * The caller is required to perform the appropriate vendor check first.
> > >   */
> > > -#define is_zen1_uarch() (!boot_cpu_has(X86_FEATURE_AMD_STIBP))
> > > -#define is_zen2_uarch()   boot_cpu_has(X86_FEATURE_AMD_STIBP)
> > > +#define is_zen1_uarch() ((boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 
> > > == 0x18) && \
> > > +                         !boot_cpu_has(X86_FEATURE_AMD_STIBP))
> > > +#define is_zen2_uarch() (boot_cpu_data.x86 == 0x17 && \
> > > +                         boot_cpu_has(X86_FEATURE_AMD_STIBP))
> > 
> > What leads you to believe there aren't Hygon Zen2's ?
> The same argument that a Hygon zen2 supports STIBP. Having seen neither HW
> nor docs all that's left is divination skills :)

There is at least one reference online, from:

https://www.tomshardware.com/news/amd-zen-china-x86-ip-license,39573.html

"THATIC* was a single-generation technology license, and there are no
additional technology licenses," Su explained, though she did not
clarify if the decision not to extend the technology transfers was a
direct result of the trade war. That means that the technology
transfer, which provided THATIC with access to the first-gen Zen
microarchitecture, will not be extended to allow the Chinese chipmaker
access to AMD's Zen 2 microarchitecture."

* Tianjin Haiguang Advanced Technology Investment Co. Ltd. (THATIC)

So I would expect there aren't any Hygon Zen2 given those claims, but
again that relies on how much you trust tomshardware.com.  The article
seems to have been reviewed by AMD as some changes were requested.

Regards, Roger.



 


Rackspace

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