backport: re PR target/68491 (libgcc calls __get_cpuid with 0 level breaks on early 486)

Backport from mainline
	2017-05-01  Uros Bizjak  <ubizjak@gmail.com>

	PR target/68491
	* config/i386/cpuid.h (__get_cpuid): Always return 0 when
	__get_cpuid_max returns 0.
	(__get_cpuid_count): Ditto.

From-SVN: r247523
This commit is contained in:
Uros Bizjak 2017-05-02 22:36:26 +02:00 committed by Uros Bizjak
parent a411c8bfb5
commit 114e5a84ae
2 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,13 @@
2017-05-02 Uros Bizjak <ubizjak@gmail.com>
Backport from mainline
2017-05-01 Uros Bizjak <ubizjak@gmail.com>
PR target/68491
* config/i386/cpuid.h (__get_cpuid): Always return 0 when
__get_cpuid_max returns 0.
(__get_cpuid_count): Ditto.
2017-05-02 Jakub Jelinek <jakub@redhat.com>
Backported from mainline

View File

@ -246,8 +246,9 @@ __get_cpuid (unsigned int __leaf,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
if (__get_cpuid_max (__ext, 0) < __leaf)
if (__maxlevel == 0 || __maxlevel < __leaf)
return 0;
__cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx);
@ -262,8 +263,9 @@ __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
if (__get_cpuid_max (__ext, 0) < __leaf)
if (__maxlevel == 0 || __maxlevel < __leaf)
return 0;
__cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);