]> err.no Git - linux-2.6/blobdiff - drivers/lguest/hypercalls.c
Remove fixed limit on number of guests, and lguests array.
[linux-2.6] / drivers / lguest / hypercalls.c
index db6caace3b9c22a7ce16a85580de212d318c4cd2..8bde20934f91e16d623b58ef94d4823e7f53a2c6 100644 (file)
@@ -205,16 +205,19 @@ static void initialize(struct lguest *lg)
                tsc_speed = 0;
 
        /* The pointer to the Guest's "struct lguest_data" is the only
-        * argument. */
-       lg->lguest_data = (struct lguest_data __user *)lg->regs->edx;
-       /* If we check the address they gave is OK now, we can simply
-        * copy_to_user/from_user from now on rather than using lgread/lgwrite.
-        * I put this in to show that I'm not immune to writing stupid
-        * optimizations. */
+        * argument.  We check that address now. */
        if (!lguest_address_ok(lg, lg->regs->edx, sizeof(*lg->lguest_data))) {
                kill_guest(lg, "bad guest page %p", lg->lguest_data);
                return;
        }
+
+       /* Having checked it, we simply set lg->lguest_data to point straight
+        * into the Launcher's memory at the right place and then use
+        * copy_to_user/from_user from now on, instead of lgread/write.  I put
+        * this in to show that I'm not immune to writing stupid
+        * optimizations. */
+       lg->lguest_data = lg->mem_base + lg->regs->edx;
+
        /* The Guest tells us where we're not to deliver interrupts by putting
         * the range of addresses into "struct lguest_data". */
        if (get_user(lg->noirq_start, &lg->lguest_data->noirq_start)
@@ -222,9 +225,7 @@ static void initialize(struct lguest *lg)
            /* We tell the Guest that it can't use the top 4MB of virtual
             * addresses used by the Switcher. */
            || put_user(4U*1024*1024, &lg->lguest_data->reserve_mem)
-           || put_user(tsc_speed, &lg->lguest_data->tsc_khz)
-           /* We also give the Guest a unique id, as used in lguest_net.c. */
-           || put_user(lg->guestid, &lg->lguest_data->guestid))
+           || put_user(tsc_speed, &lg->lguest_data->tsc_khz))
                kill_guest(lg, "bad guest page %p", lg->lguest_data);
 
        /* We write the current time into the Guest's data page once now. */
@@ -295,6 +296,6 @@ void write_timestamp(struct lguest *lg)
 {
        struct timespec now;
        ktime_get_real_ts(&now);
-       if (put_user(now, &lg->lguest_data->time))
+       if (copy_to_user(&lg->lguest_data->time, &now, sizeof(struct timespec)))
                kill_guest(lg, "Writing timestamp");
 }