aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/lguest
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/lguest')
-rw-r--r--Documentation/lguest/lguest.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 86cac3e622ab..6c8a2386cd50 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -79,6 +79,9 @@ static void *guest_base;
79/* The maximum guest physical address allowed, and maximum possible. */ 79/* The maximum guest physical address allowed, and maximum possible. */
80static unsigned long guest_limit, guest_max; 80static unsigned long guest_limit, guest_max;
81 81
82/* a per-cpu variable indicating whose vcpu is currently running */
83static unsigned int __thread cpu_id;
84
82/* This is our list of devices. */ 85/* This is our list of devices. */
83struct device_list 86struct device_list
84{ 87{
@@ -557,7 +560,7 @@ static void wake_parent(int pipefd, int lguest_fd)
557 else 560 else
558 FD_CLR(-fd - 1, &devices.infds); 561 FD_CLR(-fd - 1, &devices.infds);
559 } else /* Send LHREQ_BREAK command. */ 562 } else /* Send LHREQ_BREAK command. */
560 write(lguest_fd, args, sizeof(args)); 563 pwrite(lguest_fd, args, sizeof(args), cpu_id);
561 } 564 }
562} 565}
563 566
@@ -1530,7 +1533,8 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd)
1530 int readval; 1533 int readval;
1531 1534
1532 /* We read from the /dev/lguest device to run the Guest. */ 1535 /* We read from the /dev/lguest device to run the Guest. */
1533 readval = read(lguest_fd, &notify_addr, sizeof(notify_addr)); 1536 readval = pread(lguest_fd, &notify_addr,
1537 sizeof(notify_addr), cpu_id);
1534 1538
1535 /* One unsigned long means the Guest did HCALL_NOTIFY */ 1539 /* One unsigned long means the Guest did HCALL_NOTIFY */
1536 if (readval == sizeof(notify_addr)) { 1540 if (readval == sizeof(notify_addr)) {
@@ -1540,7 +1544,7 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd)
1540 /* ENOENT means the Guest died. Reading tells us why. */ 1544 /* ENOENT means the Guest died. Reading tells us why. */
1541 } else if (errno == ENOENT) { 1545 } else if (errno == ENOENT) {
1542 char reason[1024] = { 0 }; 1546 char reason[1024] = { 0 };
1543 read(lguest_fd, reason, sizeof(reason)-1); 1547 pread(lguest_fd, reason, sizeof(reason)-1, cpu_id);
1544 errx(1, "%s", reason); 1548 errx(1, "%s", reason);
1545 /* ERESTART means that we need to reboot the guest */ 1549 /* ERESTART means that we need to reboot the guest */
1546 } else if (errno == ERESTART) { 1550 } else if (errno == ERESTART) {
@@ -1550,9 +1554,13 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd)
1550 } else if (errno != EAGAIN) 1554 } else if (errno != EAGAIN)
1551 err(1, "Running guest failed"); 1555 err(1, "Running guest failed");
1552 1556
1557 /* Only service input on thread for CPU 0. */
1558 if (cpu_id != 0)
1559 continue;
1560
1553 /* Service input, then unset the BREAK to release the Waker. */ 1561 /* Service input, then unset the BREAK to release the Waker. */
1554 handle_input(lguest_fd); 1562 handle_input(lguest_fd);
1555 if (write(lguest_fd, args, sizeof(args)) < 0) 1563 if (pwrite(lguest_fd, args, sizeof(args), cpu_id) < 0)
1556 err(1, "Resetting break"); 1564 err(1, "Resetting break");
1557 } 1565 }
1558} 1566}
@@ -1610,6 +1618,7 @@ int main(int argc, char *argv[])
1610 devices.lastdev = &devices.dev; 1618 devices.lastdev = &devices.dev;
1611 devices.next_irq = 1; 1619 devices.next_irq = 1;
1612 1620
1621 cpu_id = 0;
1613 /* We need to know how much memory so we can set up the device 1622 /* We need to know how much memory so we can set up the device
1614 * descriptor and memory pages for the devices as we parse the command 1623 * descriptor and memory pages for the devices as we parse the command
1615 * line. So we quickly look through the arguments to find the amount 1624 * line. So we quickly look through the arguments to find the amount