svn commit: r344118 - head/sys/i386/include
Konstantin Belousov
kostikbel at gmail.com
Fri Feb 15 10:37:15 UTC 2019
On Fri, Feb 15, 2019 at 07:16:04AM +0000, Alexey Dokuchaev wrote:
> On Thu, Feb 14, 2019 at 01:53:11PM +0000, Konstantin Belousov wrote:
> > New Revision: 344118
> > URL: https://svnweb.freebsd.org/changeset/base/344118
> >
> > Log:
> > Provide userspace versions of do_cpuid() and cpuid_count() on i386.
> >
> > Some older compilers, when generating PIC code, cannot handle inline
> > asm that clobbers %ebx (because %ebx is used as the GOT offset
> > register). Userspace versions avoid clobbering %ebx by saving it to
> > stack before executing the CPUID instruction.
> >
> > ...
> > +static __inline void
> > +do_cpuid(u_int ax, u_int *p)
> > +{
> > + __asm __volatile(
> > + "pushl\t%%ebx\n\t"
> > + "cpuid\n\t"
> > + "movl\t%%ebx,%1\n\t"
> > + "popl\t%%ebx"
>
> Is there a reason to prefer pushl+movl+popl instead of movl+xchgl?
>
> "movl %%ebx, %1\n\t"
> "cpuid\n\t"
> "xchgl %%ebx, %1"
xchgl seems to be slower even in registers format (where no implicit
lock is used). If you can demonstrate that your fragment is better in
some microbenchmark, I can change it. But also note that its use is not
on the critical path.
More information about the svn-src-all
mailing list