Skip to contentSkip to conversation

uml hangs in skas mode

uml-devel Gerd Knorr 1 participant 1 message Oct 7, 2003 User-mode Linux (UML)

lore
Share & tools
lore

Gerd Knorr

author
#0 lore raw

Hi,

I ran into a uml kernel issue with the suse hardware detection tool (hwinfo). hwinfo tries to detect whenever it runs within vmware or not, and this doesn't work. hwinfo just hangs forever. The relevant part of the code to reproduce it is below.

What I've figured so far:

* hwinfo blocks in the waitpid() call, waiting for the forked child finish.
* It happens in skas mode only, tt mode is fine.
* It happens on a completely idle machine only. As soon as I start to do something in another shell hwinfo continues to run (=> scheduler race?)
* It doesn't happen if I try to "strace -f" the process.

Any idea?

Gerd

==============================[ cut here ]==============================
#define _GNU_SOURCE /* we want memmem() */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>

#include <sys/types.h>
#include <sys/wait.h>

void sigsegv_handler(int signum) { exit(77); }

int chk_vmware(void)
{
static int is_vmware = -1;
int child, status;

/* do the check only once */
if(is_vmware < 0) {

    child = fork();

    if(child == 0) {
      signal(SIGSEGV, sigsegv_handler);

      asm(
        "push %ebx\n"
        "\tpush %edx\n"
        "\tpush %eax\n"
        "\tpush %ecx\n"
        "\tmov $0x564d5868,%eax\n"
        "\tmov $0xa,%ecx\n"
        "\tmov $0x5658,%edx\n"
        "\tin (%dx),%eax\n"
        "\tpop %ecx\n"
        "\tpop %eax\n"
        "\tpop %edx\n"
        "\tpop %ebx\n"
      );

      _exit(66);
    }
    else {
      if(waitpid(child, &status, 0) == child) {
        status = WEXITSTATUS(status);
        if(status == 66) is_vmware = 1;
        if(status == 77) is_vmware = 0;
      }
    }

}
return is_vmware;
}

int main(int argc, char *argv[])

{
	int rc;

	fprintf(stderr, "check for vmware... ");
	rc = chk_vmware();
	fprintf(stderr, "%s\n", rc ? "yes" : "no");
	return rc;
}

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel