Re: [PATCH 2/6] x86: kaslr: move CPU flags out of cpucheck

H. Peter Anvin
2013-04-26T21:47:55Z

On 04/26/2013 12:03 PM, Kees Cook wrote:
> +
> +static inline void cpuid(u32 id, u32 *a, u32 *b, u32 *c, u32 *d)
> +{
> + /* Handle x86_32 PIC using ebx. */
> + asm volatile("movl %%ebx, %%edi \n\t"
> + "cpuid \n\t"
> + "xchgl %%edi, %%ebx\n\t"
> + : "=a" (*a),
> + "=D" (*b),
> + "=c" (*c),
> + "=d" (*d)
> + : "a" (id)
> + );
> +}

Please don't constrain registers unnecessarily.

You can use "=r" there and let gcc assign whatever free register it pleases.

You can also limit that to only:

#if defined(__i386__) && defined(__PIC__)

-hpa