i386 fixes PCONFIG MKTME_KEY_PROGRAM leaf number
Corrects the leaf number for MKTME_KEY_PROGRAM in i386 PCONFIG intrinsics to 0, fixing a potential #GP(0) fault.
GCC’s i386 support has corrected the leaf number for the PCONFIG MKTME_KEY_PROGRAM intrinsic. The Intel SDM specifies leaf 0 for this operation, but the code was using 1, which is the identifier for TME-MK. Using the incorrect leaf number could cause a #GP(0) fault. This change updates the intrinsic’s definition and a related test case to use the correct leaf number 0, ensuring proper PCONFIG execution.
In Details
The _pconfig_u32 intrinsic in config/i386/pconfigintrin.h previously used an incorrect leaf identifier (1) for __PCONFIG_KEY_PROGRAM. The Intel SDM specifies leaf 0 for this purpose; leaf 1 is reserved for TME-MK. This commit corrects __PCONFIG_KEY_PROGRAM to 0x00, aligning with the architecture specification and resolving a potential #GP(0) fault when using PCONFIG for MKTME key programming. A test case (pconfig-1.c) is also updated.
- PCONFIG
- A processor configuration instruction used on Intel architectures to manage various platform features, including Trusted Memory Encryption (TME).
- MKTME
- Memory Key Management Technology, a feature that allows for memory encryption using keys managed by the processor.
- leaf number
- In the context of Intel's PCONFIG instruction, different functions or operations are selected by loading a specific value into the EAX register, referred to as the 'leaf number'.
- #GP(0)
- A General Protection Fault, a type of CPU exception indicating a protection violation, often due to invalid operations or memory access.