From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Alejandro Vallejo <alejandro.vallejo@cloud.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Xen-devel <xen-devel@lists.xenproject.org>,
Jan Beulich <jbeulich@suse.com>, Wei Liu <wl@xen.org>,
Henry Wang <Henry.Wang@arm.com>
Subject: Re: [for-4.18][PATCH 1/2] xen/x86: Add family guards to the is_zen[12]_uarch() macros
Date: Fri, 13 Oct 2023 13:36:02 +0200 [thread overview]
Message-ID: <ZSkrohpG69OU8M8y@macbook> (raw)
In-Reply-To: <652928c3.170a0220.37d5e.7636@mx.google.com>
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.
next prev parent reply other threads:[~2023-10-13 11:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-12 17:25 [for-4.18][PATCH 0/2] Fix AMD erratum #1485 on AMD Zen4 Alejandro Vallejo
2023-10-12 17:26 ` [for-4.18][PATCH 1/2] xen/x86: Add family guards to the is_zen[12]_uarch() macros Alejandro Vallejo
2023-10-13 2:14 ` Andrew Cooper
2023-10-13 11:23 ` Alejandro Vallejo
2023-10-13 11:36 ` Roger Pau Monné [this message]
2023-10-13 14:00 ` Andrew Cooper
2023-10-12 17:26 ` [for-4.18][PATCH 2/2] x86/amd: Prevent potentially fetching wrong instruction bytes on Zen4 Alejandro Vallejo
2023-10-13 2:28 ` Andrew Cooper
2023-10-13 0:29 ` [for-4.18][PATCH 0/2] Fix AMD erratum #1485 on AMD Zen4 Henry Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZSkrohpG69OU8M8y@macbook \
--to=roger.pau@citrix.com \
--cc=Henry.Wang@arm.com \
--cc=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.