This patch contains a few general comments in the source code of the
driver subsystem.

Signed-off-by: Claudio Scordino <[email protected]>
---
 driver/cell.c |  3 +++
 driver/main.c | 26 +++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/driver/cell.c b/driver/cell.c
index b8c4403..56280c5 100644
--- a/driver/cell.c
+++ b/driver/cell.c
@@ -212,6 +212,7 @@ int jailhouse_cmd_cell_create(struct jailhouse_cell_create 
__user *arg)
                goto error_cell_delete;
        }
 
+       /* Off-line each CPU assigned to the new cell */
        for_each_cpu(cpu, &cell->cpus_assigned) {
                if (cpu_online(cpu)) {
                        err = cpu_down(cpu);
@@ -225,6 +226,8 @@ int jailhouse_cmd_cell_create(struct jailhouse_cell_create 
__user *arg)
        jailhouse_pci_do_all_devices(cell, JAILHOUSE_PCI_TYPE_DEVICE,
                                     JAILHOUSE_PCI_ACTION_CLAIM);
 
+       /* This hypercall will eventually dispatch the call to the cell_create()
+        * function defined in hypervisor/control.c */
        err = jailhouse_call_arg1(JAILHOUSE_HC_CELL_CREATE, __pa(config));
        if (err < 0)
                goto error_cpu_online;
diff --git a/driver/main.c b/driver/main.c
index 746de07..63d7464 100644
--- a/driver/main.c
+++ b/driver/main.c
@@ -138,6 +138,12 @@ void *jailhouse_ioremap(phys_addr_t phys, unsigned long 
virt,
        return vma->addr;
 }
 
+/**
+ * Called for each cpu by the JAILHOUSE_ENABLE ioctl.
+ * It is a thin wrapper that jumps to the entry point set in the header.
+ * The entry point is defined in hypervisor/setup.c as arch_entry, which is
+ * coded in assembler and resides in entry.S.
+ */
 static void enter_hypervisor(void *info)
 {
        struct jailhouse_header *header = info;
@@ -164,6 +170,11 @@ static void enter_hypervisor(void *info)
        atomic_inc(&call_done);
 }
 
+/**
+ * Function returning the name of the firmware to be loaded.
+ *
+ * The firmware name changes based on the arch (e.g. AMD, Intel, ARM).
+ */
 static inline const char * jailhouse_fw_name(void)
 {
 #ifdef CONFIG_X86
@@ -177,6 +188,7 @@ static inline const char * jailhouse_fw_name(void)
 #endif
 }
 
+/* @See Documentation/bootstrap-interface.txt */
 static int jailhouse_cmd_enable(struct jailhouse_system __user *arg)
 {
        const struct firmware *hypervisor;
@@ -197,7 +209,7 @@ static int jailhouse_cmd_enable(struct jailhouse_system 
__user *arg)
                return -ENODEV;
        }
 #endif
-
+       /* Get the name of the firmware to be loaded: */
        fw_name = jailhouse_fw_name();
        if (!fw_name) {
                pr_err("jailhouse: Missing or unsupported HVM technology\n");
@@ -228,6 +240,7 @@ static int jailhouse_cmd_enable(struct jailhouse_system 
__user *arg)
        if (jailhouse_enabled || !try_module_get(THIS_MODULE))
                goto error_unlock;
 
+       /* Load hypervisor image */
        err = request_firmware(&hypervisor, fw_name, jailhouse_dev);
        if (err) {
                pr_err("jailhouse: Missing hypervisor image %s\n", fw_name);
@@ -252,6 +265,8 @@ static int jailhouse_cmd_enable(struct jailhouse_system 
__user *arg)
 #ifdef JAILHOUSE_BORROW_ROOT_PT
        remap_addr = JAILHOUSE_BASE;
 #endif
+       /* Map physical memory region reserved for Jailhouse at kernel's virtual
+        * address JAILHOUSE_BASE. */
        hypervisor_mem = jailhouse_ioremap(hv_mem->phys_start, remap_addr,
                                           hv_mem->size);
        if (!hypervisor_mem) {
@@ -260,11 +275,14 @@ static int jailhouse_cmd_enable(struct jailhouse_system 
__user *arg)
                goto error_release_fw;
        }
 
+       /* Load hypervisor's binary image at beginning of the memory region */
        memcpy(hypervisor_mem, hypervisor->data, hypervisor->size);
        memset(hypervisor_mem + hypervisor->size, 0,
               hv_mem->size - hypervisor->size);
 
        header = (struct jailhouse_header *)hypervisor_mem;
+       /* Set number of max CPUs in hypervisor header according to
+        * system state */
        header->max_cpus = max_cpus;
 
        /*
@@ -276,6 +294,8 @@ static int jailhouse_cmd_enable(struct jailhouse_system 
__user *arg)
        flush_icache_range((unsigned long)hypervisor_mem,
                           (unsigned long)(hypervisor_mem + header->core_size));
 
+       /* Copy system configuration to its target address in hypervisor memory
+        * region: */
        config = (struct jailhouse_system *)
                (hypervisor_mem + hv_core_and_percpu_size);
        if (copy_from_user(config, arg, config_size)) {
@@ -311,8 +331,11 @@ static int jailhouse_cmd_enable(struct jailhouse_system 
__user *arg)
 
        preempt_disable();
 
+       /* Set number of online CPUs in hypervisor header according to
+        * system state */
        header->online_cpus = num_online_cpus();
 
+       /* Call enter_hypervisor() on each CPU. */
        atomic_set(&call_done, 0);
        on_each_cpu(enter_hypervisor, header, 0);
        while (atomic_read(&call_done) != num_online_cpus())
@@ -436,6 +459,7 @@ static int jailhouse_cmd_disable(void)
        if (err)
                goto unlock_out;
 
+       /* Unmap jailhouse's reserved memory in kernel space */
        vunmap(hypervisor_mem);
 
        jailhouse_cell_delete_root();
-- 
2.7.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to