Bug 104998 - Incorrect __cpuid usage
Summary: Incorrect __cpuid usage
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.2.1
: P3 normal
Target Milestone: 11.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-21 13:34 UTC by H.J. Lu
Modified: 2022-03-21 22:40 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-* i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2022-03-21 13:34:55 UTC
get_available_features has

  /* Get Advanced Features at level 0x19 (eax = 0x19).  */
  if (max_cpuid_level >= 0x19)
    {   
      set_feature (FEATURE_AESKLE);
      __cpuid (19, eax, ebx, ecx, edx);
               ^^^ Should be 0x19.
      /* Check if OS support keylocker.  */
      if (ebx & bit_AESKLE)
        {
          if (ebx & bit_WIDEKL)
            set_feature (FEATURE_WIDEKL);
          if (has_kl)
            set_feature (FEATURE_KL);
        }
    }
Comment 1 GCC Commits 2022-03-21 21:50:46 UTC
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:d0363a80690a299179d010c1d8a6d6430e7eb73f

commit r12-7742-gd0363a80690a299179d010c1d8a6d6430e7eb73f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Mar 21 06:50:14 2022 -0700

    x86: Properly check FEATURE_AESKLE
    
    1. Pass 0x19 to __cpuid for bit_AESKLE.
    2. Enable FEATURE_AESKLE only if bit_AESKLE is set.
    
            PR target/104998
            * common/config/i386/cpuinfo.h (get_available_features): Pass
            0x19 to __cpuid for bit_AESKLE.  Enable FEATURE_AESKLE only if
            bit_AESKLE is set.
Comment 2 GCC Commits 2022-03-21 22:38:12 UTC
The releases/gcc-11 branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:d5a493bd996e79ef175467f4b6cbcc4da119b0a1

commit r11-9675-gd5a493bd996e79ef175467f4b6cbcc4da119b0a1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Mar 21 06:50:14 2022 -0700

    x86: Properly check FEATURE_AESKLE
    
    1. Pass 0x19 to __cpuid for bit_AESKLE.
    2. Enable FEATURE_AESKLE only if bit_AESKLE is set.
    
            PR target/104998
            * common/config/i386/cpuinfo.h (get_available_features): Pass
            0x19 to __cpuid for bit_AESKLE.  Enable FEATURE_AESKLE only if
            bit_AESKLE is set.
    
    (cherry picked from commit d0363a80690a299179d010c1d8a6d6430e7eb73f)
Comment 3 H.J. Lu 2022-03-21 22:40:22 UTC
Fixed for GCC 12 and GCC 11.3.