]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: map the zero page to the full hypervisor memory region
authorAntonios Motakis <antonios.motakis@huawei.com>
Thu, 28 Apr 2016 14:01:28 +0000 (16:01 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Apr 2016 15:18:38 +0000 (17:18 +0200)
During initialization, in init_early, the hypervisor maps the
memory used by the hypervisor with empty pages for the root cell.
However, if the root cell tries to access the region used by the
hypervisor, this is only safe if both sides agree on PAGE_SIZE.
It is a long shot to try to guess the granularity used by the
root cell; the safest bet is to map the full range that has been
allocated for the hypervisor to use.

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/setup.c

index 0fb9f68eea72c05b9d315cebbb7d012239245671..98b6d85991c5f669dc571f3d8083404e228cf7a1 100644 (file)
@@ -33,6 +33,7 @@ static void init_early(unsigned int cpu_id)
 {
        unsigned long core_and_percpu_size = hypervisor_header.core_size +
                sizeof(struct per_cpu) * hypervisor_header.max_cpus;
+       unsigned long hyp_phys_start, hyp_phys_end;
        struct jailhouse_memory hv_page;
 
        master_cpu_id = cpu_id;
@@ -66,15 +67,17 @@ static void init_early(unsigned int cpu_id)
         * pages for Linux. This allows to fault-in the hypervisor region into
         * Linux' page table before shutdown without triggering violations.
         */
+       hyp_phys_start = system_config->hypervisor_memory.phys_start;
+       hyp_phys_end = hyp_phys_start + system_config->hypervisor_memory.size;
+
        hv_page.phys_start = paging_hvirt2phys(empty_page);
-       hv_page.virt_start = paging_hvirt2phys(&hypervisor_header);
+       hv_page.virt_start = hyp_phys_start;
        hv_page.size = PAGE_SIZE;
        hv_page.flags = JAILHOUSE_MEM_READ;
-       while (core_and_percpu_size > 0) {
+       while (hv_page.virt_start < hyp_phys_end) {
                error = arch_map_memory_region(&root_cell, &hv_page);
                if (error)
                        return;
-               core_and_percpu_size -= PAGE_SIZE;
                hv_page.virt_start += PAGE_SIZE;
        }