public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add macros for acessing lguest fields
@ 2007-09-10 18:20 Glauber de Oliveira Costa
  2007-09-13  6:32 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Glauber de Oliveira Costa @ 2007-09-10 18:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, rusty, rostedt, virtualization, lguest, glommer,
	Glauber de Oliveira Costa

The assumption that we have an overall irqs_pending flags,
and a one-to-one lguest <-> task mapping fails to hold on x86_64,
where we can have multiple puppies, aka vcpus.

Although ifdefs could be used, it makes the code much more
unreadable, and other ports are on the way, anyway. So some sort
of acessor is preferred anyway.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
---
 drivers/lguest/io.c |   10 +++++-----
 drivers/lguest/lg.h |    3 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/lguest/io.c b/drivers/lguest/io.c
index ea68613..70bab38 100644
--- a/drivers/lguest/io.c
+++ b/drivers/lguest/io.c
@@ -247,7 +247,7 @@ static int lgread_other(struct lguest *lg,
 			void *buf, u32 addr, unsigned bytes)
 {
 	if (!lguest_address_ok(lg, addr, bytes)
-	    || access_process_vm(lg->tsk, addr, buf, bytes, 0) != bytes) {
+	    || access_process_vm(lguest_task(lg), addr, buf, bytes, 0) != bytes) {
 		memset(buf, 0, bytes);
 		kill_guest(lg, "bad address in registered DMA struct");
 		return 0;
@@ -261,7 +261,7 @@ static int lgwrite_other(struct lguest *lg, u32 addr,
 			 const void *buf, unsigned bytes)
 {
 	if (!lguest_address_ok(lg, addr, bytes)
-	    || (access_process_vm(lg->tsk, addr, (void *)buf, bytes, 1)
+	    || (access_process_vm(lguest_task(lg), addr, (void *)buf, bytes, 1)
 		!= bytes)) {
 		kill_guest(lg, "bad address writing to registered DMA");
 		return 0;
@@ -376,7 +376,7 @@ static u32 do_dma(struct lguest *srclg, const struct lguest_dma *src,
 		 * we only want a single page.  But it works, and returns the
 		 * number of pages.  Note that we're holding the destination's
 		 * mmap_sem, as get_user_pages() requires. */
-		if (get_user_pages(dstlg->tsk, dstlg->mm,
+		if (get_user_pages(lguest_task(dstlg), dstlg->mm,
 				   dst->addr[i], 1, 1, 1, pages+i, NULL)
 		    != 1) {
 			/* This means the destination gave us a bogus buffer */
@@ -469,9 +469,9 @@ static int dma_transfer(struct lguest *srclg,
 	/* We trigger the destination interrupt, even if the destination was
 	 * empty and we didn't transfer anything: this gives them a chance to
 	 * wake up and refill. */
-	set_bit(dst->interrupt, dstlg->irqs_pending);
+	set_bit(dst->interrupt, lguest_irqs_pending(dstlg));
 	/* Wake up the destination process. */
-	wake_up_process(dstlg->tsk);
+	wake_up_process(lguest_task(dstlg));
 	/* If we passed the last "struct lguest_dma", the receive had no
 	 * buffers left. */
 	return i == dst->num_dmas;
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index 64f0abe..b1ed671 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -258,6 +258,9 @@ unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
 void do_hypercalls(struct lguest *lg);
 void write_timestamp(struct lguest *lg);
 
+#define lguest_task(__lg) __lg->tsk
+#define lguest_irqs_pending(__lg) __lg->irqs_pending
+
 /*L:035
  * Let's step aside for the moment, to study one important routine that's used
  * widely in the Host code.
-- 
1.4.4.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add macros for acessing lguest fields
  2007-09-10 18:20 [PATCH] Add macros for acessing lguest fields Glauber de Oliveira Costa
@ 2007-09-13  6:32 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2007-09-13  6:32 UTC (permalink / raw)
  To: Glauber de Oliveira Costa
  Cc: linux-kernel, akpm, rostedt, virtualization, lguest, glommer

On Mon, 2007-09-10 at 15:20 -0300, Glauber de Oliveira Costa wrote:
> The assumption that we have an overall irqs_pending flags,
> and a one-to-one lguest <-> task mapping fails to hold on x86_64,
> where we can have multiple puppies, aka vcpus.
> 
> Although ifdefs could be used, it makes the code much more
> unreadable, and other ports are on the way, anyway. So some sort
> of acessor is preferred anyway.

I'd prefer to see the i386 code use vcpus too.  Even if i386 only has
one at present, it's cleaner.

Of course, there'll be a lot of "s/lg/vcpu/" churn, but that's OK.

Thanks,
Rusty.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-13  6:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-10 18:20 [PATCH] Add macros for acessing lguest fields Glauber de Oliveira Costa
2007-09-13  6:32 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox