All of lore.kernel.org
 help / color / mirror / Atom feed
From: ehrhardt@linux.vnet.ibm.com
To: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, avi@qumranet.com
Cc: hollisb@us.ibm.com, ehrhardt@linux.vnet.ibm.com
Subject: [PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c
Date: Tue, 28 Oct 2008 09:08:18 +0000	[thread overview]
Message-ID: <1225184902-25769-2-git-send-email-ehrhardt@linux.vnet.ibm.com> (raw)
In-Reply-To: <1225184902-25769-1-git-send-email-ehrhardt@linux.vnet.ibm.com>

From: Hollis Blanchard <hollisb@us.ibm.com>

- call io_table_register() before any vcpus have started
- wait for all vcpus to exit before exiting the parent thread

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---

[diffstat]
 main-ppc.c |   32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

[diff]
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -51,7 +51,7 @@ struct io_table mmio_table;
 struct io_table mmio_table;
 
 static int ncpus = 1;
-static sem_t init_sem;
+static sem_t exited_sem;
 static __thread int vcpu;
 static sigset_t kernel_sigmask;
 static sigset_t ipi_sigmask;
@@ -220,16 +220,8 @@ void sync_caches(void *mem, unsigned lon
 	asm volatile ("sync; isync");
 }
 
-static void init_vcpu(int n, unsigned long entry)
+static void init_vcpu(int n)
 {
-	/* XXX must set initial TLB state and stack
-	struct kvm_regs regs = {
-		.pc = entry,
-	};
-
-	kvm_set_regs(kvm, 0, &regs);
-	*/
-
 	sigemptyset(&ipi_sigmask);
 	sigaddset(&ipi_sigmask, IPI_SIGNAL);
 	sigprocmask(SIG_UNBLOCK, &ipi_sigmask, NULL);
@@ -237,7 +229,6 @@ static void init_vcpu(int n, unsigned lo
 	vcpus[n].tid = gettid();
 	vcpu = n;
 	kvm_set_signal_mask(kvm, n, &kernel_sigmask);
-	sem_post(&init_sem);
 }
 
 static void *do_create_vcpu(void *_n)
@@ -245,8 +236,9 @@ static void *do_create_vcpu(void *_n)
 	int n = (long)_n;
 
 	kvm_create_vcpu(kvm, n);
-	init_vcpu(n, 0x0);
+	init_vcpu(n);
 	kvm_run(kvm, n);
+	sem_post(&exited_sem);
 	return NULL;
 }
 
@@ -368,14 +360,14 @@ int main(int argc, char **argv)
 	len = load_file(vm_mem, argv[optind], 1);
 	sync_caches(vm_mem, len);
 
-	sem_init(&init_sem, 0, 0);
-	init_vcpu(0, 0x0);
-	for (i = 1; i < ncpus; ++i)
-		start_vcpu(i);
-	for (i = 0; i < ncpus; ++i)
-		sem_wait(&init_sem);
-
 	io_table_register(&mmio_table, 0xf0000000, 64, mmio_handler, NULL);
 
-	return kvm_run(kvm, 0);
+	sem_init(&exited_sem, 0, 0);
+	for (i = 0; i < ncpus; ++i)
+		start_vcpu(i);
+	/* Wait for all vcpus to exit. */
+	for (i = 0; i < ncpus; ++i)
+		sem_wait(&exited_sem);
+
+	return 0;
 }

WARNING: multiple messages have this Message-ID (diff)
From: ehrhardt@linux.vnet.ibm.com
To: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, avi@qumranet.com
Cc: hollisb@us.ibm.com, ehrhardt@linux.vnet.ibm.com
Subject: [PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c
Date: Tue, 28 Oct 2008 10:08:18 +0100	[thread overview]
Message-ID: <1225184902-25769-2-git-send-email-ehrhardt@linux.vnet.ibm.com> (raw)
In-Reply-To: <1225184902-25769-1-git-send-email-ehrhardt@linux.vnet.ibm.com>

From: Hollis Blanchard <hollisb@us.ibm.com>

- call io_table_register() before any vcpus have started
- wait for all vcpus to exit before exiting the parent thread

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---

[diffstat]
 main-ppc.c |   32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

[diff]
diff --git a/user/main-ppc.c b/user/main-ppc.c
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -51,7 +51,7 @@ struct io_table mmio_table;
 struct io_table mmio_table;
 
 static int ncpus = 1;
-static sem_t init_sem;
+static sem_t exited_sem;
 static __thread int vcpu;
 static sigset_t kernel_sigmask;
 static sigset_t ipi_sigmask;
@@ -220,16 +220,8 @@ void sync_caches(void *mem, unsigned lon
 	asm volatile ("sync; isync");
 }
 
-static void init_vcpu(int n, unsigned long entry)
+static void init_vcpu(int n)
 {
-	/* XXX must set initial TLB state and stack
-	struct kvm_regs regs = {
-		.pc = entry,
-	};
-
-	kvm_set_regs(kvm, 0, &regs);
-	*/
-
 	sigemptyset(&ipi_sigmask);
 	sigaddset(&ipi_sigmask, IPI_SIGNAL);
 	sigprocmask(SIG_UNBLOCK, &ipi_sigmask, NULL);
@@ -237,7 +229,6 @@ static void init_vcpu(int n, unsigned lo
 	vcpus[n].tid = gettid();
 	vcpu = n;
 	kvm_set_signal_mask(kvm, n, &kernel_sigmask);
-	sem_post(&init_sem);
 }
 
 static void *do_create_vcpu(void *_n)
@@ -245,8 +236,9 @@ static void *do_create_vcpu(void *_n)
 	int n = (long)_n;
 
 	kvm_create_vcpu(kvm, n);
-	init_vcpu(n, 0x0);
+	init_vcpu(n);
 	kvm_run(kvm, n);
+	sem_post(&exited_sem);
 	return NULL;
 }
 
@@ -368,14 +360,14 @@ int main(int argc, char **argv)
 	len = load_file(vm_mem, argv[optind], 1);
 	sync_caches(vm_mem, len);
 
-	sem_init(&init_sem, 0, 0);
-	init_vcpu(0, 0x0);
-	for (i = 1; i < ncpus; ++i)
-		start_vcpu(i);
-	for (i = 0; i < ncpus; ++i)
-		sem_wait(&init_sem);
-
 	io_table_register(&mmio_table, 0xf0000000, 64, mmio_handler, NULL);
 
-	return kvm_run(kvm, 0);
+	sem_init(&exited_sem, 0, 0);
+	for (i = 0; i < ncpus; ++i)
+		start_vcpu(i);
+	/* Wait for all vcpus to exit. */
+	for (i = 0; i < ncpus; ++i)
+		sem_wait(&exited_sem);
+
+	return 0;
 }

  reply	other threads:[~2008-10-28  9:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28  9:08 [PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc ehrhardt
2008-10-28  9:08 ` ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
2008-10-28  9:08 ` ehrhardt [this message]
2008-10-28  9:08   ` [PATCH 1/5] user: ppc: fix threading bugs in main-ppc.c ehrhardt
2008-10-28  9:08 ` [PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc ehrhardt
2008-10-28  9:08   ` [Qemu-devel] " ehrhardt
2008-10-28  9:08   ` ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
2008-10-28  9:08 ` [PATCH 2/5] user: ppc: better error reporting in load_file ehrhardt
2008-10-28  9:08   ` ehrhardt
2008-10-28  9:08 ` [PATCH 4/5] libcflat: ppc: add timebase accessor ehrhardt
2008-10-28  9:08   ` ehrhardt
     [not found] ` <1225184902-25769-1-git-send-email-ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-10-28  9:08   ` [PATCH 3/5] user: ppc: implement PowerPC 44x libcflat ehrhardt
2008-10-28  9:08     ` ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
2008-10-28  9:08   ` [PATCH 5/5] user: ppc: add stub nmi handler ehrhardt
2008-10-28  9:08     ` ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
2008-10-28  9:25   ` [PATCH 0/3] kvm-userspace: ppc: userspace fixes for powerpc Christian Ehrhardt
2008-10-28  9:25     ` Christian Ehrhardt

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=1225184902-25769-2-git-send-email-ehrhardt@linux.vnet.ibm.com \
    --to=ehrhardt@linux.vnet.ibm.com \
    --cc=avi@qumranet.com \
    --cc=hollisb@us.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    /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.