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

Tigran Aivazian (tigran@sco.COM)
Tue, 7 Jul 1998 17:53:14 +0100 (BST)


Hello,

Thanks, about 20 seconds before I got your mail I figured that one out by
reading some ASM faq on the net, the version that looks like:

.text
.align 4
.globl _hw
_hw:
cpuid
movl $1, %eax
movl $0, %ebx
int $0x80

works fine (and I link it with ld -e _hw)

Thanks,
------
Tigran A. Aivazian | http://www.sco.com/
Escalations Research Group | Email: tigran@sco.com
Santa Cruz Operation Ltd |

On Tue, 7 Jul 1998, Martin Mares wrote:

> > 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?
>
> Because it executes your two instruction and then continues with executing
> invalid instructions after your program. Try adding
>
> movl $0, %eax
> movl %eax, %ebx
> int $0x80
>
> to call exit(0) at the end.
>
> Have a nice fortnight
> --
> Martin `MJ' Mares <mj@ucw.cz> http://atrey.karlin.mff.cuni.cz/~mj/
> Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
> "They'll release Windows 96 when 95 finishes loading."
>

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