aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/domain_builder/dom_builder.c30
-rw-r--r--xen-2.4.16/common/dom0_ops.c4
-rw-r--r--xen-2.4.16/common/domain.c4
-rw-r--r--xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c10
4 files changed, 31 insertions, 17 deletions
diff --git a/tools/domain_builder/dom_builder.c b/tools/domain_builder/dom_builder.c
index 1a9199f2a1..d2df002a67 100644
--- a/tools/domain_builder/dom_builder.c
+++ b/tools/domain_builder/dom_builder.c
@@ -11,6 +11,7 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <stdlib.h>
#include "hypervisor_defs.h"
#include "dom0_ops.h"
@@ -25,9 +26,6 @@
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)
#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED|_PAGE_DIRTY)
-/* Round _n up to nearest multiple of _m. */
-#define ROUND_UP(_n,_m) (((_n) + (_m) - 1) / (_m))
-
/* standardized error reporting function */
static void dberr(char *msg)
{
@@ -203,7 +201,6 @@ static int do_kernel_chcks(char *image, long dom_size,
close(fd);
goto out;
}
- *ksize = stat.st_size - SIG_LEN;
read(fd, signature, SIG_LEN);
if(strncmp(signature, GUEST_SIG, SIG_LEN)){
@@ -216,6 +213,8 @@ static int do_kernel_chcks(char *image, long dom_size,
read(fd, load_addr, sizeof(unsigned long));
+ *ksize = stat.st_size - SIG_LEN - sizeof(unsigned long);
+
sprintf(status, "Kernel image %s valid, kernel virtual load address %lx",
image, *load_addr);
dbstatus(status);
@@ -252,13 +251,16 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
int cmd_fd;
meminfo = (dom_meminfo_t *)malloc(sizeof(dom_meminfo_t));
- page_array = (unsigned long *)dom_mem->vaddr;
+ page_array = malloc(dom_mem->tot_pages * 4);
pgt_updates = (page_update_request_t *)dom_mem->vaddr;
alloc_index = dom_mem->tot_pages - 1;
+ memcpy(page_array, (void *)dom_mem->vaddr, dom_mem->tot_pages * 4);
+
/* Count bottom-level PTs, rounding up. Include one PTE for shared info. */
- num_pt_pages = ROUND_UP(l1_table_offset(virt_load_addr) +
- dom_mem->tot_pages + 1, 1024);
+ num_pt_pages =
+ (l1_table_offset(virt_load_addr) + dom_mem->tot_pages + 1024) / 1024;
+
/* We must also count the page directory. */
num_pt_pages++;
@@ -282,9 +284,13 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
pgt_updates++;
num_pgt_updates++;
- /* Initialise the page tables. */
+ /*
+ * Initialise the page tables. The final iteration is for the shared_info
+ * PTE -- we break out before filling in the entry, as that is done by
+ * Xen during final setup.
+ */
l2tab += l2_table_offset(virt_load_addr) * sizeof(l2_pgentry_t);
- for ( count = 0; count < dom_mem->tot_pages; count++ )
+ for ( count = 0; count < (dom_mem->tot_pages + 1); count++ )
{
if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
{
@@ -302,6 +308,9 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
num_pgt_updates++;
l2tab += sizeof(l2_pgentry_t);
}
+
+ /* The last PTE we consider is filled in later by Xen. */
+ if ( count == dom_mem->tot_pages ) break;
if ( count < pt_start )
{
@@ -344,7 +353,8 @@ static dom_meminfo_t *setup_guestos(int dom, int kernel_fd,
close(cmd_fd);
/* Load the guest OS image. */
- if(!(read(kernel_fd, (char *)dom_mem->vaddr, ksize) > 0)){
+ if( read(kernel_fd, (char *)dom_mem->vaddr, ksize) != ksize )
+ {
dberr("Error reading kernel image, could not"
" read the whole image. Terminating.\n");
goto out;
diff --git a/xen-2.4.16/common/dom0_ops.c b/xen-2.4.16/common/dom0_ops.c
index c2eae723c0..4d0caaa96a 100644
--- a/xen-2.4.16/common/dom0_ops.c
+++ b/xen-2.4.16/common/dom0_ops.c
@@ -72,8 +72,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
case DOM0_STARTDOM:
{
struct task_struct * p = find_domain_by_id(op.u.meminfo.domain);
- ret = final_setup_guestos(p, &op.u.meminfo);
- if( ret != 0 ){
+ if ( (ret = final_setup_guestos(p, &op.u.meminfo)) != 0 )
+ {
p->state = TASK_DYING;
release_task(p);
break;
diff --git a/xen-2.4.16/common/domain.c b/xen-2.4.16/common/domain.c
index cb24e0cdce..3535b45e50 100644
--- a/xen-2.4.16/common/domain.c
+++ b/xen-2.4.16/common/domain.c
@@ -262,8 +262,8 @@ int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo)
unmap_domain_mem((void *)((unsigned long)l1tab & PAGE_MASK));
/* set up the shared info structure */
- update_dom_time(p->shared_info);
- p->shared_info->cpu_freq = cpu_freq;
+ update_dom_time(p->shared_info);
+ p->shared_info->cpu_freq = cpu_freq;
p->shared_info->domain_time = 0;
/* we pass start info struct to guest os as function parameter on stack */
diff --git a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c
index f8a6ea93ea..0cc35d9832 100644
--- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c
+++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c
@@ -194,7 +194,8 @@ static int cmd_write_proc(struct file *file, const char *buffer,
int ret = 0;
struct proc_dir_entry * new_dom_id;
dom0_newdomain_t * params;
-
+ int i;
+ unsigned long p;
copy_from_user(&op, buffer, sizeof(dom0_op_t));
@@ -211,8 +212,11 @@ static int cmd_write_proc(struct file *file, const char *buffer,
}
else if ( op.cmd == DO_PGUPDATES )
{
- ret = HYPERVISOR_pt_update((void *)op.u.pgupdate.pgt_update_arr,
- op.u.pgupdate.num_pgt_updates);
+ p = op.u.pgupdate.pgt_update_arr;
+ for ( i = 0; i < op.u.pgupdate.num_pgt_updates; i++ )
+ {
+ ret = HYPERVISOR_pt_update(p + i*8, 1);
+ }
}
else
{