From 100723a89eb5f83df26dfdc30cac6a38e2eaec85 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 25 Nov 2004 11:45:09 +0000 Subject: [PATCH 1/4] bitkeeper revision 1.1159.194.1 (41a5c5c5J8BRAOOMMsDGqEcd_8brmg) Sort exception tables during Xen boot. This will fix some nasty crashes that some people have seen in the last day or so. --- xen/arch/x86/extable.c | 36 +++++++++++++++++++++++----- xen/arch/x86/setup.c | 2 ++ xen/include/asm-x86/x86_32/uaccess.h | 1 + 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c index 54251cc3c5..d3292027e0 100644 --- a/xen/arch/x86/extable.c +++ b/xen/arch/x86/extable.c @@ -3,6 +3,36 @@ #include #include +extern struct exception_table_entry __start___ex_table[]; +extern struct exception_table_entry __stop___ex_table[]; +extern struct exception_table_entry __start___pre_ex_table[]; +extern struct exception_table_entry __stop___pre_ex_table[]; + +static void sort_exception_table(struct exception_table_entry *start, + struct exception_table_entry *end) +{ + struct exception_table_entry *p, *q, tmp; + + for ( p = start; p < end; p++ ) + { + for ( q = p-1; q > start; q-- ) + if ( p->insn > q->insn ) + break; + if ( ++q != p ) + { + tmp = *p; + memmove(q+1, q, (p-q)*sizeof(*p)); + *q = tmp; + } + } +} + +void sort_exception_tables(void) +{ + sort_exception_table(__start___ex_table, __stop___ex_table); + sort_exception_table(__start___pre_ex_table, __stop___pre_ex_table); +} + static inline unsigned long search_one_table(const struct exception_table_entry *first, const struct exception_table_entry *last, @@ -28,21 +58,15 @@ search_one_table(const struct exception_table_entry *first, unsigned long search_exception_table(unsigned long addr) { - extern const struct exception_table_entry __start___ex_table[]; - extern const struct exception_table_entry __stop___ex_table[]; return search_one_table( __start___ex_table, __stop___ex_table-1, addr); } -#ifdef __i386__ unsigned long search_pre_exception_table(unsigned long addr) { - extern const struct exception_table_entry __start___pre_ex_table[]; - extern const struct exception_table_entry __stop___pre_ex_table[]; unsigned long fixup = search_one_table( __start___pre_ex_table, __stop___pre_ex_table-1, addr); DPRINTK("Pre-exception: %08lx -> %08lx\n", addr, fixup); return fixup; } -#endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 7ed4bf0744..cf6f7980e1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -326,6 +326,8 @@ void __init start_of_day(void) if ( opt_watchdog ) nmi_watchdog = NMI_LOCAL_APIC; + sort_exception_tables(); + /* Tell the PCI layer not to allocate too close to the RAM area.. */ low_mem_size = ((max_page << PAGE_SHIFT) + 0xfffff) & ~0xfffff; if ( low_mem_size > pci_mem_start ) pci_mem_start = low_mem_size; diff --git a/xen/include/asm-x86/x86_32/uaccess.h b/xen/include/asm-x86/x86_32/uaccess.h index 1b1b28bfe5..7531a29445 100644 --- a/xen/include/asm-x86/x86_32/uaccess.h +++ b/xen/include/asm-x86/x86_32/uaccess.h @@ -85,6 +85,7 @@ struct exception_table_entry }; extern unsigned long search_exception_table(unsigned long); +extern void sort_exception_tables(void); /** * get_user: - Get a simple variable from user space. From 5574c165a26196c7bbaa49e6a2fd69b42cd47841 Mon Sep 17 00:00:00 2001 From: "cl349@arcadians.cl.cam.ac.uk" Date: Thu, 25 Nov 2004 14:05:15 +0000 Subject: [PATCH 2/4] bitkeeper revision 1.1159.194.2 (41a5e69b3tIuTQ0hJ7dj4VL-MmKxuw) entry.S: Use __USER_DS for %ds/%es in kernel, like regular i386 Linux. --- linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S index f8f0b8c4fa..82be1d521d 100644 --- a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S +++ b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S @@ -102,10 +102,9 @@ VM_MASK = 0x00020000 pushl %edx; \ pushl %ecx; \ pushl %ebx; \ - movl $(__KERNEL_DS), %edx; \ + movl $(__USER_DS), %edx; \ movl %edx, %ds; \ movl %edx, %es; - # XXXcl USER? #define RESTORE_INT_REGS \ popl %ebx; \ From a540583964c7009cb4543ae1128e52a346f7ff55 Mon Sep 17 00:00:00 2001 From: "cl349@arcadians.cl.cam.ac.uk" Date: Thu, 25 Nov 2004 14:07:37 +0000 Subject: [PATCH 3/4] bitkeeper revision 1.1159.194.3 (41a5e729R9jXVAOcrKU-Xq81RscJQQ) vbd.c, block.h: Fix mapping from Xen device numbers to Linux device names. --- linux-2.6.9-xen-sparse/drivers/xen/blkfront/block.h | 3 ++- linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/linux-2.6.9-xen-sparse/drivers/xen/blkfront/block.h b/linux-2.6.9-xen-sparse/drivers/xen/blkfront/block.h index ace010e0fb..f50ce03bca 100644 --- a/linux-2.6.9-xen-sparse/drivers/xen/blkfront/block.h +++ b/linux-2.6.9-xen-sparse/drivers/xen/blkfront/block.h @@ -64,6 +64,7 @@ struct xlbd_type_info { int partn_shift; + int partn_per_major; int devs_per_major; int hardsect_size; int max_sectors; @@ -77,8 +78,8 @@ struct xlbd_type_info { */ struct xlbd_major_info { int major; + int index; int usage; - int xd_device; struct xlbd_type_info *type; }; diff --git a/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c b/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c index d2cfb7cf5a..684db78e99 100644 --- a/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c +++ b/linux-2.6.9-xen-sparse/drivers/xen/blkfront/vbd.c @@ -44,6 +44,7 @@ static struct xlbd_type_info xlbd_ide_type = { .partn_shift = 6, + .partn_per_major = 2, // XXXcl todo blksize_size[major] = 1024; .hardsect_size = 512, .max_sectors = 128, /* 'hwif->rqsize' if we knew it */ @@ -53,6 +54,7 @@ static struct xlbd_type_info xlbd_ide_type = { static struct xlbd_type_info xlbd_scsi_type = { .partn_shift = 4, + .partn_per_major = 16, // XXXcl todo blksize_size[major] = 1024; /* XXX 512; */ .hardsect_size = 512, .max_sectors = 128*8, /* XXX 128; */ @@ -62,6 +64,7 @@ static struct xlbd_type_info xlbd_scsi_type = { static struct xlbd_type_info xlbd_vbd_type = { .partn_shift = 4, + .partn_per_major = 16, // XXXcl todo blksize_size[major] = 512; .hardsect_size = 512, .max_sectors = 128, @@ -167,13 +170,17 @@ static struct xlbd_major_info *xlbd_get_major_info(int xd_device, int *minor) switch (mi_idx) { case 0 ... (NUM_IDE_MAJORS - 1): major_info[mi_idx]->type = &xlbd_ide_type; + major_info[mi_idx]->index = mi_idx; break; case NUM_IDE_MAJORS ... (NUM_IDE_MAJORS + NUM_SCSI_MAJORS - 1): major_info[mi_idx]->type = &xlbd_scsi_type; + major_info[mi_idx]->index = mi_idx - NUM_IDE_MAJORS; break; case (NUM_IDE_MAJORS + NUM_SCSI_MAJORS) ... (NUM_IDE_MAJORS + NUM_SCSI_MAJORS + NUM_VBD_MAJORS - 1): major_info[mi_idx]->type = &xlbd_vbd_type; + major_info[mi_idx]->index = mi_idx - + (NUM_IDE_MAJORS + NUM_SCSI_MAJORS); break; } major_info[mi_idx]->major = new_major; @@ -222,7 +229,8 @@ static struct gendisk *xlvbd_get_gendisk(struct xlbd_major_info *mi, gd->fops = &xlvbd_block_fops; gd->private_data = di; sprintf(gd->disk_name, "%s%c%d", mi->type->name, - 'a' + (xd_minor >> mi->type->partn_shift), + 'a' + mi->index * mi->type->partn_per_major + + (xd_minor >> mi->type->partn_shift), xd_minor & ((1 << mi->type->partn_shift) - 1)); /* sprintf(gd->devfs_name, "%s%s/disc%d", mi->type->name, , ); XXXdevfs */ From c584b005711d7fe6d79287a87a5e7152a2050cde Mon Sep 17 00:00:00 2001 From: "cl349@arcadians.cl.cam.ac.uk" Date: Thu, 25 Nov 2004 14:08:23 +0000 Subject: [PATCH 4/4] bitkeeper revision 1.1159.194.4 (41a5e757kS3W0lQ0UXkviQYcgBr7Gg) XendDomainInfo.py: Fix check for no configured block devices. --- tools/python/xen/xend/XendDomainInfo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 963a0c8ea8..335da5e486 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -994,13 +994,13 @@ class XendDomainInfo: @return: deferred """ - if (self.get_devices("vbd") == None): + if self.get_devices("vbd") == []: ctrl = xend.blkif_create(self.dom, recreate=self.recreate) back = ctrl.getBackendInterface(0) return back.connect(recreate=self.recreate) else: return None - + def dom_construct(self, dom, config): """Construct a vm for an existing domain.