aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2007-10-21 21:03:31 -0400
committerRusty Russell <rusty@rustcorp.com.au>2007-10-23 01:49:52 -0400
commit511801dc31c095b2bfe3bf5c6a370dbe9b042a70 (patch)
treefcd0f1111e503f33e39660d3aba55ff5b64ebf56 /drivers/lguest
parentb410e7b1499c49513cab18275db8a8ab549d9e09 (diff)
Change example launcher to use unsigned long not u32
Apply Clue 2x4 to lguest userland<->kernel handling code and the lguest launcher. Pointers are not to be passed in u32's! Basic rule of thumb: Anything passing u32's back and forth should be passing unsigned longs to be portable to 64 bit archs. For those who forgotten already, I repeat: NO POINTERS IN u32! Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest')
-rw-r--r--drivers/lguest/lguest_user.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 5632ed82798a..d4ac5f846427 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -43,7 +43,7 @@ static void setup_regs(struct lguest_regs *regs, unsigned long start)
43/*L:310 To send DMA into the Guest, the Launcher needs to be able to ask for a 43/*L:310 To send DMA into the Guest, the Launcher needs to be able to ask for a
44 * DMA buffer. This is done by writing LHREQ_GETDMA and the key to 44 * DMA buffer. This is done by writing LHREQ_GETDMA and the key to
45 * /dev/lguest. */ 45 * /dev/lguest. */
46static long user_get_dma(struct lguest *lg, const u32 __user *input) 46static long user_get_dma(struct lguest *lg, const unsigned long __user *input)
47{ 47{
48 unsigned long key, udma, irq; 48 unsigned long key, udma, irq;
49 49
@@ -67,7 +67,7 @@ static long user_get_dma(struct lguest *lg, const u32 __user *input)
67/*L:315 To force the Guest to stop running and return to the Launcher, the 67/*L:315 To force the Guest to stop running and return to the Launcher, the
68 * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The 68 * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The
69 * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */ 69 * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */
70static int break_guest_out(struct lguest *lg, const u32 __user *input) 70static int break_guest_out(struct lguest *lg, const unsigned long __user *input)
71{ 71{
72 unsigned long on; 72 unsigned long on;
73 73
@@ -90,9 +90,9 @@ static int break_guest_out(struct lguest *lg, const u32 __user *input)
90 90
91/*L:050 Sending an interrupt is done by writing LHREQ_IRQ and an interrupt 91/*L:050 Sending an interrupt is done by writing LHREQ_IRQ and an interrupt
92 * number to /dev/lguest. */ 92 * number to /dev/lguest. */
93static int user_send_irq(struct lguest *lg, const u32 __user *input) 93static int user_send_irq(struct lguest *lg, const unsigned long __user *input)
94{ 94{
95 u32 irq; 95 unsigned long irq;
96 96
97 if (get_user(irq, input) != 0) 97 if (get_user(irq, input) != 0)
98 return -EFAULT; 98 return -EFAULT;
@@ -142,8 +142,8 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
142 return run_guest(lg, (unsigned long __user *)user); 142 return run_guest(lg, (unsigned long __user *)user);
143} 143}
144 144
145/*L:020 The initialization write supplies 5 32-bit values (in addition to the 145/*L:020 The initialization write supplies 5 pointer sized (32 or 64 bit)
146 * 32-bit LHREQ_INITIALIZE value). These are: 146 * values (in addition to the LHREQ_INITIALIZE value). These are:
147 * 147 *
148 * base: The start of the Guest-physical memory inside the Launcher memory. 148 * base: The start of the Guest-physical memory inside the Launcher memory.
149 * 149 *
@@ -162,13 +162,13 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
162 * quickly converted from physical to virtual by adding PAGE_OFFSET. It's 162 * quickly converted from physical to virtual by adding PAGE_OFFSET. It's
163 * 0xC0000000 (3G) by default, but it's configurable at kernel build time. 163 * 0xC0000000 (3G) by default, but it's configurable at kernel build time.
164 */ 164 */
165static int initialize(struct file *file, const u32 __user *input) 165static int initialize(struct file *file, const unsigned long __user *input)
166{ 166{
167 /* "struct lguest" contains everything we (the Host) know about a 167 /* "struct lguest" contains everything we (the Host) know about a
168 * Guest. */ 168 * Guest. */
169 struct lguest *lg; 169 struct lguest *lg;
170 int err; 170 int err;
171 u32 args[5]; 171 unsigned long args[5];
172 172
173 /* We grab the Big Lguest lock, which protects against multiple 173 /* We grab the Big Lguest lock, which protects against multiple
174 * simultaneous initializations. */ 174 * simultaneous initializations. */
@@ -259,17 +259,18 @@ unlock:
259 * start with a 32 bit number: for the first write this must be 259 * start with a 32 bit number: for the first write this must be
260 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use 260 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use
261 * writes of other values to get DMA buffers and send interrupts. */ 261 * writes of other values to get DMA buffers and send interrupts. */
262static ssize_t write(struct file *file, const char __user *input, 262static ssize_t write(struct file *file, const char __user *in,
263 size_t size, loff_t *off) 263 size_t size, loff_t *off)
264{ 264{
265 /* Once the guest is initialized, we hold the "struct lguest" in the 265 /* Once the guest is initialized, we hold the "struct lguest" in the
266 * file private data. */ 266 * file private data. */
267 struct lguest *lg = file->private_data; 267 struct lguest *lg = file->private_data;
268 u32 req; 268 const unsigned long __user *input = (const unsigned long __user *)in;
269 unsigned long req;
269 270
270 if (get_user(req, input) != 0) 271 if (get_user(req, input) != 0)
271 return -EFAULT; 272 return -EFAULT;
272 input += sizeof(req); 273 input++;
273 274
274 /* If you haven't initialized, you must do that first. */ 275 /* If you haven't initialized, you must do that first. */
275 if (req != LHREQ_INITIALIZE && !lg) 276 if (req != LHREQ_INITIALIZE && !lg)
@@ -285,13 +286,13 @@ static ssize_t write(struct file *file, const char __user *input,
285 286
286 switch (req) { 287 switch (req) {
287 case LHREQ_INITIALIZE: 288 case LHREQ_INITIALIZE:
288 return initialize(file, (const u32 __user *)input); 289 return initialize(file, input);
289 case LHREQ_GETDMA: 290 case LHREQ_GETDMA:
290 return user_get_dma(lg, (const u32 __user *)input); 291 return user_get_dma(lg, input);
291 case LHREQ_IRQ: 292 case LHREQ_IRQ:
292 return user_send_irq(lg, (const u32 __user *)input); 293 return user_send_irq(lg, input);
293 case LHREQ_BREAK: 294 case LHREQ_BREAK:
294 return break_guest_out(lg, (const u32 __user *)input); 295 return break_guest_out(lg, input);
295 default: 296 default:
296 return -EINVAL; 297 return -EINVAL;
297 } 298 }