]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
driver: Prevent disabling when there are offlined CPUs
authorJan Kiszka <jan.kiszka@siemens.com>
Fri, 15 May 2015 07:57:41 +0000 (09:57 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Fri, 15 May 2015 08:00:09 +0000 (10:00 +0200)
If Linux has some of the CPUs offlined itself, i.e. not for passing them
to other cells, and we disable the hypervisor then, those CPUs will not
be released. Attempts to online them again later on will fail. Reject
disable requests in such a case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
driver/cell.c
driver/cell.h
driver/main.c

index d88d1eceac511ce05da3319ca4f4785bfb98d576..4dbaab43c7676e47a114d8dc1d90391b91c640de 100644 (file)
@@ -22,8 +22,9 @@
 
 #include <jailhouse/hypercall.h>
 
+struct cell *root_cell;
+
 static LIST_HEAD(cells);
-static struct cell *root_cell;
 static cpumask_t offlined_cpus;
 
 void jailhouse_cell_kobj_release(struct kobject *kobj)
index aec60653d35c4b733ca91d0d31f59ad7866cae98..1ee5a4818ff76015b3023be527d5d82dd581ad05 100644 (file)
@@ -35,6 +35,8 @@ struct cell {
 #endif /* CONFIG_PCI */
 };
 
+extern struct cell *root_cell;
+
 void jailhouse_cell_kobj_release(struct kobject *kobj);
 
 struct cell *
index f3a08f31524369c49f3703fc808dc8b5f697924f..fececf9bffd09aa04a60d594f1eb69d42db1b601 100644 (file)
@@ -363,6 +363,18 @@ static int jailhouse_cmd_disable(void)
 
        preempt_disable();
 
+       if (num_online_cpus() != cpumask_weight(&root_cell->cpus_assigned)) {
+               /*
+                * Not all assigned CPUs are currently online. If we disable
+                * now, we will loose the offlined ones.
+                */
+
+               preempt_enable();
+
+               err = -EBUSY;
+               goto unlock_out;
+       }
+
        atomic_set(&call_done, 0);
        on_each_cpu(leave_hypervisor, NULL, 0);
        while (atomic_read(&call_done) != num_online_cpus())