[PATCH] Add macros for acessing lguest fields

Previous thread: [PATCH] Intel FB: support for interlaced video modes by Krzysztof Halasa on Monday, September 10, 2007 - 12:28 pm. (1 message)

Next thread: RFC: possible bug in load_elf_binary by Chris Friesen on Monday, September 10, 2007 - 2:28 pm. (5 messages)
From: Glauber de Oliveira Costa
Date: Monday, September 10, 2007 - 11:20 am

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 ...
From: Rusty Russell
Date: Wednesday, September 12, 2007 - 11:32 pm

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.


-

Previous thread: [PATCH] Intel FB: support for interlaced video modes by Krzysztof Halasa on Monday, September 10, 2007 - 12:28 pm. (1 message)

Next thread: RFC: possible bug in load_elf_binary by Chris Friesen on Monday, September 10, 2007 - 2:28 pm. (5 messages)