IBM Support

How to disable CPU Feature / Flag HLE "Hardware Lock Elision" on RHEL x86 - intel

How To


Summary

In some systems, HLE "Hardware Lock Elision" is required to be off as a feature / flag on a RHEL systems for some application specific reasons. The steps below will let you know how to configure your system to disable this feature/flag, and how to identify the flag/feature identity number.

Steps

1. Check if the feature/flag is turned on by running the below command :
 
[root@knop1 ~]# cat /proc/cpuinfo  | grep hle
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm
constant_tsc rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes
xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase
bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat md_clear spec_ctrl
We can see it is enabled in the above output.  In order to disable it we will need to identify the bit number of that feature/flag for the x86 architecture from the source code as well as the kernel parameter that is needed to apply to the boot CMDLINE.
2. In order to do that we need to have a look on the kernel-parameters.txt from the kernel.org link can be found below :
https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt
We find clearcpuid parameter with the description below :
clearcpuid=BITNUM[,BITNUM...] [X86]
			Disable CPUID feature X for the kernel. See
			arch/x86/include/asm/cpufeatures.h for the valid bit
			numbers. Note the Linux specific bits are not necessarily
			stable over kernel options, but the vendor specific
			ones should be.
			Also note that user programs calling CPUID directly
			or using the feature without checking anything
			will still see it. This just prevents it from
			being used by the kernel or shown in /proc/cpuinfo.
			Also note the kernel might malfunction if you disable
			some critical bits.
3. In that case we need to find the valid bit number for this feature which we can find in the mentioned source code file.  This is the bit number for this feature that we need to disable through the below link :
https://github.com/torvalds/linux/blob/master/tools/arch/x86/include/asm/cpufeatures.h
Looking at the source code we found HLE feature mentioned with the bit number ( 9*32+ 4)
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
#define X86_FEATURE_FSGSBASE		( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
#define X86_FEATURE_TSC_ADJUST		( 9*32+ 1) /* TSC adjustment MSR 0x3B */
#define X86_FEATURE_SGX			( 9*32+ 2) /* Software Guard Extensions */
#define X86_FEATURE_BMI1		( 9*32+ 3) /* 1st group bit manipulation extensions */
#define X86_FEATURE_HLE			( 9*32+ 4) /* Hardware Lock Elision */
4. We will need to calculate the decimal value of that bit number by running the simple calculation below :

9 × 32 + 4 = 292

Our decimal value for clearcpuid kernel parameter is 292 , clearcpuid=292

5. We will need to apply it to CMDLINE in grub so the system will boot with that parameter :

5.1. Modify the /etc/default/grub as shown and add ONLY clearcpuid=292 at the end of the CMDLINE like below  :

[root@knop1 ~]# vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet elevator=noop clearcpuid=292 "
GRUB_DISABLE_RECOVERY="true"

5.2. Save and Quit.

5.3.  Run the below command to rebuild the grub configuration file :

grub2-mkconfig -o /boot/grub2/grub.cfg

[root@knop1 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.65.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.65.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.61.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.61.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.56.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.56.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-cbb00030e5204543a0474ffff17ec26f
Found initrd image: /boot/initramfs-0-rescue-cbb00030e5204543a0474ffff17ec26f.img
done

5.4.  Reboot the system and you will see that the feature is now disabled

5.5  When the system boots you can check by running the below command  :

cat /proc/cpuinfo | grep -i hle

output should be looking like the below without the HLE feature/flag :

[root@knop1 ~]# cat /proc/cpuinfo  | grep -i hle
[root@knop1 ~]# 

Document Location

Worldwide

[{"Line of Business":{"code":"LOB26","label":"Storage"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SGMV157","label":"IBM Support for Red Hat Enterprise Linux Server"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Product Synonym

Linux; RHEL;

Document Information

Modified date:
11 February 2021

UID

ibm16414755