[Lguest] [TUTORIAL 1/2] M-hiofix: Writes to a shared mapping not bound by a guest go to the launcher

Paul TBBle Hampson Paul.Hampson at Pobox.com
Thu Jan 31 21:15:30 EST 2008


---
 drivers/lguest/io.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/lguest/io.c b/drivers/lguest/io.c
index ea68613..39adf79 100644
--- a/drivers/lguest/io.c
+++ b/drivers/lguest/io.c
@@ -488,6 +488,7 @@ void send_dma(struct lguest *lg, unsigned long ukey, unsigned long udma)
 	union futex_key key;
 	int empty = 0;
 	struct rw_semaphore *fshared = &current->mm->mmap_sem;
+	int found_guest = 0;
 
 again:
 	mutex_lock(&lguest_lock);
@@ -510,6 +511,9 @@ again:
 			if (!key_eq(&key, &i->key))
 				continue;
 
+			/* We found a guest to send to. */
+			found_guest = 1;
+
 			/* If dma_transfer() tells us the destination has no
 			 * available buffers, we increment "empty". */
 			empty += dma_transfer(lg, udma, i);
@@ -525,10 +529,12 @@ again:
 			empty++;
 			goto again;
 		}
-	} else {
-		/* Private mapping: Guest is sending to its Launcher.  We set
-		 * the "dma_is_pending" flag so that the main loop will exit
-		 * and the Launcher's read() from /dev/lguest will return. */
+	}
+	if (found_guest == 0) {
+		/* Private mapping or a shared mapping which no guest has bound:
+		 * Guest is sending to its Launcher.  We set the "dma_is_pending"
+		 * flag so that the main loop will exit and the Launcher's read()
+		 * from /dev/lguest will return. */
 		lg->dma_is_pending = 1;
 		lg->pending_dma = udma;
 		lg->pending_key = ukey;
-- 
1.5.3.8


-- 
-----------------------------------------------------------
Paul "TBBle" Hampson, B.Sc, LPI, MCSE
Very-later-year Asian Studies student, ANU
The Boss, Bubblesworth Pty Ltd (ABN: 51 095 284 361)
Paul.Hampson at Pobox.com

Of course Pacman didn't influence us as kids. If it did,
we'd be running around in darkened rooms, popping pills and
listening to repetitive music.
 -- Kristian Wilson, Nintendo, Inc, 1989

License: http://creativecommons.org/licenses/by/2.1/au/
-----------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/lguest/attachments/20080131/e92015cd/attachment.pgp>


More information about the Lguest mailing list