Brendan Shanks bshanks@codeweavers.com writes:
+extern int have_cpuid (void );
+extern void do_cpuid_cx( unsigned int ax, unsigned int cx, unsigned int *p ); +__ASM_GLOBAL_FUNC( do_cpuid_cx,
"pushl %esi\n\t"
"pushl %ebx\n\t"
"movl 12(%esp),%eax\n\t"
"movl 16(%esp),%ecx\n\t"
"movl 20(%esp),%esi\n\t"
"cpuid\n\t"
"movl %eax,(%esi)\n\t"
"movl %ebx,4(%esi)\n\t"
"movl %ecx,8(%esi)\n\t"
"movl %edx,12(%esi)\n\t"
"popl %ebx\n\t"
"popl %esi\n\t"
"ret" )
+static int umip_enabled( void ) +{
- /* Check cpuid to see if UMIP is supported.
* UMIP bit is EAX=0x07,ECX=0x0, ECX bit 2
* (CPUID.07H.0H:ECX:UMIP[bit 2] in Intel syntax)
*
* It would be preferable to check if UMIP is actually enabled
* (CR4.UMIP), but that can't be done from userspace.
*/
- unsigned int regs[4];
- if (!have_cpuid()) return 0;
- do_cpuid_cx( 0x00000000, 0, regs ); /* get standard cpuid level and vendor name */
- if (regs[0] >= 0x00000007) /* Check for supported cpuid version */
- {
do_cpuid_cx( 0x00000007, 0, regs );
if (regs[2] & (1 << 2))
return 1;
- }
- return 0;
+} +#endif
There shouldn't be any reason to check this. If UMIP is not enabled you won't get a fault in the first place.
Also I don't see why you use #ifdef linux, surely that code could work on other platforms too.