aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest/lguest_user.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-10-21 21:24:10 -0400
committerRusty Russell <rusty@rustcorp.com.au>2007-10-23 01:49:55 -0400
commit15045275c32bf6d15d32c2eca8157be9c0ba6e45 (patch)
tree32ef90c875b22cb1bbb94e38f557a690f1c0c6f8 /drivers/lguest/lguest_user.c
parent0ca49ca946409f87a8cd0b14d5acb6dea58de6f3 (diff)
Remove old lguest I/O infrrasructure.
This patch gets rid of the old lguest host I/O infrastructure and replaces it with a single hypercall "LHCALL_NOTIFY" which takes an address. The main change is the removal of io.c: that mainly did inter-guest I/O, which virtio doesn't yet support. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/lguest_user.c')
-rw-r--r--drivers/lguest/lguest_user.c39
1 files changed, 5 insertions, 34 deletions
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 61b177e1e649..ee405b38383d 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -2,37 +2,12 @@
2 * controls and communicates with the Guest. For example, the first write will 2 * controls and communicates with the Guest. For example, the first write will
3 * tell us the Guest's memory layout, pagetable, entry point and kernel address 3 * tell us the Guest's memory layout, pagetable, entry point and kernel address
4 * offset. A read will run the Guest until something happens, such as a signal 4 * offset. A read will run the Guest until something happens, such as a signal
5 * or the Guest doing a DMA out to the Launcher. Writes are also used to get a 5 * or the Guest doing a NOTIFY out to the Launcher. :*/
6 * DMA buffer registered by the Guest and to send the Guest an interrupt. :*/
7#include <linux/uaccess.h> 6#include <linux/uaccess.h>
8#include <linux/miscdevice.h> 7#include <linux/miscdevice.h>
9#include <linux/fs.h> 8#include <linux/fs.h>
10#include "lg.h" 9#include "lg.h"
11 10
12/*L:310 To send DMA into the Guest, the Launcher needs to be able to ask for a
13 * DMA buffer. This is done by writing LHREQ_GETDMA and the key to
14 * /dev/lguest. */
15static long user_get_dma(struct lguest *lg, const unsigned long __user *input)
16{
17 unsigned long key, udma, irq;
18
19 /* Fetch the key they wrote to us. */
20 if (get_user(key, input) != 0)
21 return -EFAULT;
22 /* Look for a free Guest DMA buffer bound to that key. */
23 udma = get_dma_buffer(lg, key, &irq);
24 if (!udma)
25 return -ENOENT;
26
27 /* We need to tell the Launcher what interrupt the Guest expects after
28 * the buffer is filled. We stash it in udma->used_len. */
29 lgwrite_u32(lg, udma + offsetof(struct lguest_dma, used_len), irq);
30
31 /* The (guest-physical) address of the DMA buffer is returned from
32 * the write(). */
33 return udma;
34}
35
36/*L:315 To force the Guest to stop running and return to the Launcher, the 11/*L:315 To force the Guest to stop running and return to the Launcher, the
37 * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The 12 * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The
38 * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */ 13 * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */
@@ -102,10 +77,10 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
102 return len; 77 return len;
103 } 78 }
104 79
105 /* If we returned from read() last time because the Guest sent DMA, 80 /* If we returned from read() last time because the Guest notified,
106 * clear the flag. */ 81 * clear the flag. */
107 if (lg->dma_is_pending) 82 if (lg->pending_notify)
108 lg->dma_is_pending = 0; 83 lg->pending_notify = 0;
109 84
110 /* Run the Guest until something interesting happens. */ 85 /* Run the Guest until something interesting happens. */
111 return run_guest(lg, (unsigned long __user *)user); 86 return run_guest(lg, (unsigned long __user *)user);
@@ -216,7 +191,7 @@ unlock:
216/*L:010 The first operation the Launcher does must be a write. All writes 191/*L:010 The first operation the Launcher does must be a write. All writes
217 * start with a 32 bit number: for the first write this must be 192 * start with a 32 bit number: for the first write this must be
218 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use 193 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use
219 * writes of other values to get DMA buffers and send interrupts. */ 194 * writes of other values to send interrupts. */
220static ssize_t write(struct file *file, const char __user *in, 195static ssize_t write(struct file *file, const char __user *in,
221 size_t size, loff_t *off) 196 size_t size, loff_t *off)
222{ 197{
@@ -245,8 +220,6 @@ static ssize_t write(struct file *file, const char __user *in,
245 switch (req) { 220 switch (req) {
246 case LHREQ_INITIALIZE: 221 case LHREQ_INITIALIZE:
247 return initialize(file, input); 222 return initialize(file, input);
248 case LHREQ_GETDMA:
249 return user_get_dma(lg, input);
250 case LHREQ_IRQ: 223 case LHREQ_IRQ:
251 return user_send_irq(lg, input); 224 return user_send_irq(lg, input);
252 case LHREQ_BREAK: 225 case LHREQ_BREAK:
@@ -276,8 +249,6 @@ static int close(struct inode *inode, struct file *file)
276 mutex_lock(&lguest_lock); 249 mutex_lock(&lguest_lock);
277 /* Cancels the hrtimer set via LHCALL_SET_CLOCKEVENT. */ 250 /* Cancels the hrtimer set via LHCALL_SET_CLOCKEVENT. */
278 hrtimer_cancel(&lg->hrt); 251 hrtimer_cancel(&lg->hrt);
279 /* Free any DMA buffers the Guest had bound. */
280 release_all_dma(lg);
281 /* Free up the shadow page tables for the Guest. */ 252 /* Free up the shadow page tables for the Guest. */
282 free_guest_pagetable(lg); 253 free_guest_pagetable(lg);
283 /* Now all the memory cleanups are done, it's safe to release the 254 /* Now all the memory cleanups are done, it's safe to release the