diff options
-rw-r--r-- | Documentation/lguest/lguest.c | 27 | ||||
-rw-r--r-- | drivers/lguest/lguest_user.c | 31 |
2 files changed, 30 insertions, 28 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index 140bd98a8417..4950b03514e6 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -473,9 +473,9 @@ static unsigned long setup_pagetables(unsigned long mem, | |||
473 | unsigned long initrd_size, | 473 | unsigned long initrd_size, |
474 | unsigned long page_offset) | 474 | unsigned long page_offset) |
475 | { | 475 | { |
476 | u32 *pgdir, *linear; | 476 | unsigned long *pgdir, *linear; |
477 | unsigned int mapped_pages, i, linear_pages; | 477 | unsigned int mapped_pages, i, linear_pages; |
478 | unsigned int ptes_per_page = getpagesize()/sizeof(u32); | 478 | unsigned int ptes_per_page = getpagesize()/sizeof(void *); |
479 | 479 | ||
480 | /* Ideally we map all physical memory starting at page_offset. | 480 | /* Ideally we map all physical memory starting at page_offset. |
481 | * However, if page_offset is 0xC0000000 we can only map 1G of physical | 481 | * However, if page_offset is 0xC0000000 we can only map 1G of physical |
@@ -505,7 +505,7 @@ static unsigned long setup_pagetables(unsigned long mem, | |||
505 | * continue from there. */ | 505 | * continue from there. */ |
506 | for (i = 0; i < mapped_pages; i += ptes_per_page) { | 506 | for (i = 0; i < mapped_pages; i += ptes_per_page) { |
507 | pgdir[(i + page_offset/getpagesize())/ptes_per_page] | 507 | pgdir[(i + page_offset/getpagesize())/ptes_per_page] |
508 | = ((to_guest_phys(linear) + i*sizeof(u32)) | 508 | = ((to_guest_phys(linear) + i*sizeof(void *)) |
509 | | PAGE_PRESENT); | 509 | | PAGE_PRESENT); |
510 | } | 510 | } |
511 | 511 | ||
@@ -537,12 +537,13 @@ static void concat(char *dst, char *args[]) | |||
537 | * the base of guest "physical" memory, the top physical page to allow, the | 537 | * the base of guest "physical" memory, the top physical page to allow, the |
538 | * top level pagetable, the entry point and the page_offset constant for the | 538 | * top level pagetable, the entry point and the page_offset constant for the |
539 | * Guest. */ | 539 | * Guest. */ |
540 | static int tell_kernel(u32 pgdir, u32 start, u32 page_offset) | 540 | static int tell_kernel(unsigned long pgdir, unsigned long start, |
541 | unsigned long page_offset) | ||
541 | { | 542 | { |
542 | u32 args[] = { LHREQ_INITIALIZE, | 543 | unsigned long args[] = { LHREQ_INITIALIZE, |
543 | (unsigned long)guest_base, | 544 | (unsigned long)guest_base, |
544 | guest_limit / getpagesize(), | 545 | guest_limit / getpagesize(), |
545 | pgdir, start, page_offset }; | 546 | pgdir, start, page_offset }; |
546 | int fd; | 547 | int fd; |
547 | 548 | ||
548 | verbose("Guest: %p - %p (%#lx)\n", | 549 | verbose("Guest: %p - %p (%#lx)\n", |
@@ -586,7 +587,7 @@ static void wake_parent(int pipefd, int lguest_fd, struct device_list *devices) | |||
586 | 587 | ||
587 | for (;;) { | 588 | for (;;) { |
588 | fd_set rfds = devices->infds; | 589 | fd_set rfds = devices->infds; |
589 | u32 args[] = { LHREQ_BREAK, 1 }; | 590 | unsigned long args[] = { LHREQ_BREAK, 1 }; |
590 | 591 | ||
591 | /* Wait until input is ready from one of the devices. */ | 592 | /* Wait until input is ready from one of the devices. */ |
592 | select(devices->max_infd+1, &rfds, NULL, NULL, NULL); | 593 | select(devices->max_infd+1, &rfds, NULL, NULL, NULL); |
@@ -684,7 +685,7 @@ static u32 *dma2iov(unsigned long dma, struct iovec iov[], unsigned *num) | |||
684 | static u32 *get_dma_buffer(int fd, void *key, | 685 | static u32 *get_dma_buffer(int fd, void *key, |
685 | struct iovec iov[], unsigned int *num, u32 *irq) | 686 | struct iovec iov[], unsigned int *num, u32 *irq) |
686 | { | 687 | { |
687 | u32 buf[] = { LHREQ_GETDMA, to_guest_phys(key) }; | 688 | unsigned long buf[] = { LHREQ_GETDMA, to_guest_phys(key) }; |
688 | unsigned long udma; | 689 | unsigned long udma; |
689 | u32 *res; | 690 | u32 *res; |
690 | 691 | ||
@@ -705,7 +706,7 @@ static u32 *get_dma_buffer(int fd, void *key, | |||
705 | /* This is a convenient routine to send the Guest an interrupt. */ | 706 | /* This is a convenient routine to send the Guest an interrupt. */ |
706 | static void trigger_irq(int fd, u32 irq) | 707 | static void trigger_irq(int fd, u32 irq) |
707 | { | 708 | { |
708 | u32 buf[] = { LHREQ_IRQ, irq }; | 709 | unsigned long buf[] = { LHREQ_IRQ, irq }; |
709 | if (write(fd, buf, sizeof(buf)) != 0) | 710 | if (write(fd, buf, sizeof(buf)) != 0) |
710 | err(1, "Triggering irq %i", irq); | 711 | err(1, "Triggering irq %i", irq); |
711 | } | 712 | } |
@@ -787,7 +788,7 @@ static bool handle_console_input(int fd, struct device *dev) | |||
787 | struct timeval now; | 788 | struct timeval now; |
788 | gettimeofday(&now, NULL); | 789 | gettimeofday(&now, NULL); |
789 | if (now.tv_sec <= abort->start.tv_sec+1) { | 790 | if (now.tv_sec <= abort->start.tv_sec+1) { |
790 | u32 args[] = { LHREQ_BREAK, 0 }; | 791 | unsigned long args[] = { LHREQ_BREAK, 0 }; |
791 | /* Close the fd so Waker will know it has to | 792 | /* Close the fd so Waker will know it has to |
792 | * exit. */ | 793 | * exit. */ |
793 | close(waker_fd); | 794 | close(waker_fd); |
@@ -1365,7 +1366,7 @@ static void __attribute__((noreturn)) | |||
1365 | run_guest(int lguest_fd, struct device_list *device_list) | 1366 | run_guest(int lguest_fd, struct device_list *device_list) |
1366 | { | 1367 | { |
1367 | for (;;) { | 1368 | for (;;) { |
1368 | u32 args[] = { LHREQ_BREAK, 0 }; | 1369 | unsigned long args[] = { LHREQ_BREAK, 0 }; |
1369 | unsigned long arr[2]; | 1370 | unsigned long arr[2]; |
1370 | int readval; | 1371 | int readval; |
1371 | 1372 | ||
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. */ |
46 | static long user_get_dma(struct lguest *lg, const u32 __user *input) | 46 | static 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. */ |
70 | static int break_guest_out(struct lguest *lg, const u32 __user *input) | 70 | static 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. */ |
93 | static int user_send_irq(struct lguest *lg, const u32 __user *input) | 93 | static 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 | */ |
165 | static int initialize(struct file *file, const u32 __user *input) | 165 | static 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. */ |
262 | static ssize_t write(struct file *file, const char __user *input, | 262 | static 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 | } |