All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Knorr <kraxel@bytesex.org>
To: uml devel <user-mode-linux-devel@lists.sourceforge.net>
Subject: [uml-devel] uml hangs in skas mode
Date: Tue, 7 Oct 2003 11:59:15 +0200	[thread overview]
Message-ID: <20031007095915.GA2849@bytesex.org> (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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

                 reply	other threads:[~2003-10-07  9:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031007095915.GA2849@bytesex.org \
    --to=kraxel@bytesex.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.