Re: Linux 2.1.108: SIGSEGV on doing cpuid in ring 3

H. Peter Anvin (hpa@transmeta.com)
7 Jul 1998 17:01:27 GMT


Followup to: <Pine.LNX.3.96.980707165735.554A-100000@einstein.london.sco.com>
By author: Tigran Aivazian <tigran@sco.COM>
In newsgroup: linux.dev.kernel
>
> Hello,
>
> I tried to run the following trivial asm program:
>
> movl $0, %eax
> cpuid
>
> which was built as:
>
> $ as cpuid.s -o cpuid.o
> $ ld cpuid.o -o cpuid
> ld: warning: cannot find entry symbol _start; defaulting to 08048074
> $ ./cpuid
> Segmentation fault (core dumped)
>
> The Intel PII manual says (on page 3-70 of Volume 2) that CPUID can be
> used in any ring so I don't need to be in the kernel.
>
> Any ideas why it gets a SIGSEGV?
>

So it runs the CPUID, then what happens? You don't have anything to
halt execution, so it keeps going and eventually run off the page --
kaboom.

Oh yeah, and you don't have a _start symbol either.

Try this:

_start:
movl $0, %eax
cpuid

movl $1, %eax ! exit
movl $0, %ebx ! arg = 0
int $0x80 ! system call

-- 
    PGP: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD  1E DF FE 69 EE 35 BD 74
    See http://www.zytor.com/~hpa/ for web page and full PGP public key
        I am Bahá'í -- ask me about it or see http://www.bahai.org/
   "To love another person is to see the face of God." -- Les Misérables

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu