ChangeSet 1.1277.1.1, 2005/04/11 08:14:40-06:00, djm@djmnc4000.(none)
Add domU restart capability.
Signed-off by: Dan Magenheimer (dan.magenheimer@xxxxxx)
arch/ia64/domain.c | 31 ++++++++++++++++++++++++++++---
arch/ia64/hypercall.c | 10 +++++++++-
arch/ia64/process.c | 4 ++--
arch/ia64/xenmisc.c | 9 ++++++++-
include/asm-ia64/config.h | 3 ++-
include/asm-ia64/domain.h | 5 +++++
6 files changed, 54 insertions(+), 8 deletions(-)
diff -Nru a/xen/arch/ia64/domain.c b/xen/arch/ia64/domain.c
--- a/xen/arch/ia64/domain.c 2005-04-20 05:02:52 -04:00
+++ b/xen/arch/ia64/domain.c 2005-04-20 05:02:52 -04:00
@@ -258,8 +258,8 @@
sw->ar_pfs = 0;
sw->ar_bspstore = new_rbs;
//regs->r13 = (unsigned long) ed;
-printf("new_thread: ed=%p, regs=%p, sw=%p, new_rbs=%p, IA64_STK_OFFSET=%p,
&r8=%p\n",
-ed,regs,sw,new_rbs,IA64_STK_OFFSET,®s->r8);
+printf("new_thread: ed=%p, start_pc=%p, regs=%p, sw=%p, new_rbs=%p,
IA64_STK_OFFSET=%p, &r8=%p\n",
+ed,start_pc,regs,sw,new_rbs,IA64_STK_OFFSET,®s->r8);
sw->b0 = (unsigned long) &ia64_ret_from_clone;
ed->thread.ksp = (unsigned long) sw - 16;
//ed->thread_info->flags = 0;
@@ -428,6 +428,7 @@
int h, filesz, memsz, paddr;
unsigned long elfaddr, dom_mpaddr, dom_imva;
struct page *p;
+ unsigned long pteval;
copy_memory(&ehdr,image_start,sizeof(Elf_Ehdr));
for ( h = 0; h < ehdr.e_phnum; h++ ) {
@@ -456,9 +457,15 @@
else
#endif
while (memsz > 0) {
+#ifdef DOMU_AUTO_RESTART
+ pteval = lookup_domain_mpa(d,dom_mpaddr);
+ if (pteval) dom_imva = __va(pteval & _PFN_MASK);
+ else { printf("loaddomainelfimage: BAD!\n"); while(1); }
+#else
p = map_new_domain_page(d,dom_mpaddr);
if (unlikely(!p)) BUG();
dom_imva = __va(page_to_phys(p));
+#endif
if (filesz > 0) {
if (filesz >= PAGE_SIZE)
copy_memory(dom_imva,elfaddr,PAGE_SIZE);
@@ -774,7 +781,9 @@
struct exec_domain *ed = d->exec_domain[0];
unsigned long pkern_entry;
+#ifndef DOMU_AUTO_RESTART
if ( test_bit(DF_CONSTRUCTED, &d->d_flags) ) BUG();
+#endif
printk("*** LOADING DOMAIN %d ***\n",d->id);
@@ -808,13 +817,29 @@
set_bit(DF_CONSTRUCTED, &d->d_flags);
- printk("calling new_thread\n");
+ printk("calling new_thread, entry=%p\n",pkern_entry);
+#ifdef DOMU_AUTO_RESTART
+ ed->domain->arch.image_start = image_start;
+ ed->domain->arch.image_len = image_len;
+ ed->domain->arch.entry = pkern_entry;
+#endif
new_thread(ed, pkern_entry, 0, 0);
printk("new_thread returns\n");
__set_bit(0x30,ed->vcpu_info->arch.delivery_mask);
return 0;
}
+
+#ifdef DOMU_AUTO_RESTART
+void reconstruct_domU(struct exec_domain *ed)
+{
+ /* re-copy the OS image to reset data values to original */
+ printk("reconstruct_domU: restarting domain %d...\n",
+ ed->domain->id);
+ loaddomainelfimage(ed->domain,ed->domain->arch.image_start);
+ new_thread(ed, ed->domain->arch.entry, 0, 0);
+}
+#endif
// FIXME: When dom0 can construct domains, this goes away (or is rewritten)
int launch_domainU(unsigned long size)
diff -Nru a/xen/arch/ia64/hypercall.c b/xen/arch/ia64/hypercall.c
--- a/xen/arch/ia64/hypercall.c 2005-04-20 05:02:52 -04:00
+++ b/xen/arch/ia64/hypercall.c 2005-04-20 05:02:52 -04:00
@@ -21,7 +21,7 @@
void fooefi(void) {}
-void
+int
ia64_hypercall (struct pt_regs *regs)
{
struct exec_domain *ed = (struct domain *) current;
@@ -50,8 +50,15 @@
printf("(by dom0)\n ");
(*efi.reset_system)(EFI_RESET_WARM,0,0,NULL);
}
+#ifdef DOMU_AUTO_RESTART
+ else {
+ reconstruct_domU(current);
+ return 0; // don't increment ip!
+ }
+#else
printf("(not supported for non-0 domain)\n");
regs->r8 = EFI_UNSUPPORTED;
+#endif
break;
case FW_HYPERCALL_EFI_GET_TIME:
fooefi();
@@ -105,4 +112,5 @@
regs->r8 = domU_staging_read_8(vcpu_get_gr(ed,32));
break;
}
+ return 1;
}
diff -Nru a/xen/arch/ia64/process.c b/xen/arch/ia64/process.c
--- a/xen/arch/ia64/process.c 2005-04-20 05:02:52 -04:00
+++ b/xen/arch/ia64/process.c 2005-04-20 05:02:52 -04:00
@@ -714,8 +714,8 @@
else do_ssc(vcpu_get_gr(current,36), regs);
}
else if (iim == d->breakimm) {
- ia64_hypercall(regs);
- vcpu_increment_iip(current);
+ if (ia64_hypercall(regs))
+ vcpu_increment_iip(current);
}
else reflect_interruption(ifa,isr,iim,regs,IA64_BREAK_VECTOR);
}
diff -Nru a/xen/arch/ia64/xenmisc.c b/xen/arch/ia64/xenmisc.c
--- a/xen/arch/ia64/xenmisc.c 2005-04-20 05:02:52 -04:00
+++ b/xen/arch/ia64/xenmisc.c 2005-04-20 05:02:52 -04:00
@@ -276,6 +276,7 @@
extern spinlock_t console_lock;
unsigned long flags;
+loop:
printf("$$$$$ PANIC in domain %d (k6=%p): ",
ed->domain->id, ia64_get_kr(IA64_KR_CURRENT));
va_start(args, fmt);
@@ -285,5 +286,11 @@
if (regs) show_registers(regs);
domain_pause_by_systemcontroller(current->domain);
set_bit(DF_CRASHED, ed->domain->d_flags);
- //while(test);
+ if (ed->domain->id == 0) {
+ int i = 1000000000L;
+ // if domain0 crashes, just periodically print out panic
+ // message to make post-mortem easier
+ while(i--);
+ goto loop;
+ }
}
diff -Nru a/xen/include/asm-ia64/config.h b/xen/include/asm-ia64/config.h
--- a/xen/include/asm-ia64/config.h 2005-04-20 05:02:52 -04:00
+++ b/xen/include/asm-ia64/config.h 2005-04-20 05:02:52 -04:00
@@ -1,8 +1,9 @@
// control flags for turning on/off features under test
#undef CLONE_DOMAIN0
-//#define CLONE_DOMAIN0 5
+//#define CLONE_DOMAIN0 1
#define DOMU_BUILD_STAGING
#define VHPT_GLOBAL
+#define DOMU_AUTO_RESTART
// manufactured from component pieces
diff -Nru a/xen/include/asm-ia64/domain.h b/xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h 2005-04-20 05:02:52 -04:00
+++ b/xen/include/asm-ia64/domain.h 2005-04-20 05:02:52 -04:00
@@ -21,6 +21,11 @@
u64 xen_vastart;
u64 xen_vaend;
u64 shared_info_va;
+#ifdef DOMU_AUTO_RESTART
+ u64 image_start;
+ u64 image_len;
+ u64 entry;
+#endif
};
#define metaphysical_rid arch.metaphysical_rid
#define starting_rid arch.starting_rid
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|