Re: [PATCH v2] i386: Fix __get_cpuid() and __get_cpuid_count() for Centaur/Zhaoxin CPUID range

"Ewan Hai-oc" <[email protected]> Thu, 6 Aug 2026 10:51:42 +0800
Newsgroups gmane.comp.gcc.patches
Message-ID <20260806025142.pf5vs2ue4lo2ikhi@ewan-server>
On Tue, Mar 17, 2026 at 09:27:13AM +0100, Uros Bizjak wrote:
> On Tue, Mar 17, 2026 at 9:12 AM Ewanhaioc <[email protected]> wrote:
> >
> > From: Ewan <[email protected]>
> >
> > The __get_cpuid() and __get_cpuid_count() functions use
> > "__leaf & 0x80000000" to determine the CPUID range base, which only
> > distinguishes between Basic (0x0) and Extended (0x80000000) ranges.
> > This causes queries to the Centaur/Zhaoxin range (0xC0000000) to be
> > incorrectly mapped to the Extended range, and always return 0 (failure)
> > on Centaur/Zhaoxin processors that support CPUID 0xC000xxxx
> > leaves (e.g. PadLock feature detection via leaf 0xC0000001).
> >
> > Replace the bitmask with explicit range checks that correctly identify
> > all four CPUID ranges: Basic (0x0), Hypervisor (0x40000000), Extended
> > (0x80000000), and Centaur/Zhaoxin (0xC0000000).
> >
> > Additionally, the Hypervisor range (0x40000000) is also handled as an
> > extra improvement, since the original bitmask incorrectly mapped it to
> > the Basic range (0x0).
> >
> > Also update the __get_cpuid_max() comment to document the newly
> > supported range base values.
> >
> > gcc/ChangeLog:
> >
> >         * config/i386/cpuid.h (__get_cpuid_max): Update comment to
> >         document 0x40000000 and 0xC0000000 as valid ext values.
> >         (__get_cpuid): Replace "__leaf & 0x80000000" with explicit
> >         range checks for Basic, Hypervisor, Extended, and
> >         Centaur/Zhaoxin CPUID ranges.
> >         (__get_cpuid_count): Likewise.
> 
> OK.
> 
> Thanks,
> Uros.
>

Ping. This patch was approved on March 17, but it does not appear to have reached master yet.
It still applies cleanly to current master. Could someone please commit it?