Solaris x86 should use HLT instruction / was: Re: solaris x86 7 as guest?

Solaris x86 should use HLT instruction / was: Re: solaris x86 7 as guest?

Post by Roland Main » Sat, 15 Jul 2000 04:00:00




Quote:> > If you can execute 'HLT' instruction from userspace, do it...

> > asm { "1:\n\thlt\n\tjmps 1b\n" }

> > and run it as low priority task... Problem is that without
> > some additional ops (iopl?) it will not work, it gets killed by
> > kernel due to access violation.

> I had a go at that; but no joy - it segvs. In case someone can suggest
> something
> else by looking at my attempt - here it is. Every cpu cycle is precious
> :)

> Paul
> --
> #include <stdio.h>
> #include <errno.h>
> #if defined(linux)
> #include <sys/io.h>
> #elif defined (SOLX86)
> #include <sys/sysi86.h>
> #include <sys/v86.h>
> #include <sys/psw.h>
> #endif

> int
> main(int argc, char* argv[])
> {
> #if defined(linux)
>    if (iopl(0)==-1) {
>       fprintf(stderr, "iopl: can't change to 3 - %s\n",
> strerror(errno));
>       return -1;
>       }
> #elif defined (SOLX86)
>    if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
>       fprintf(stderr, "iopl: failed - %s\n", strerror(errno));
>       return -1;
>       }
>    /* (void)sysi86(SI86V86, V86SC_IOPL, 0);*/
> #else
> #error bados
> #endif

>    for(;;) __asm__("hlt");

>    return 0;
> }

No, this code can't work in userspace.
As Casper Dik wrote some days ago a low-priority kernel thread can do
this. Maybe someone with enougth Solaris x86 knowlegde can convert the
code above into a kernel module which runs the for(;;) __asm__("hlt");
in a kernel thread with the lowest available priority.
And if this solves the problem the kernel module can be shipped as a
part of VMware Tools for Solaris x86 :-)

----

Bye,
Roland

--
  __ .  . __


  /O /==\ O\  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
 (;O/ \/ \O;) TEL +49 641 99-13193 FAX +49 641 99-41359