# HG changeset patch
# User djm@xxxxxxxxxxxxxxx
# Node ID fdea4a967bc77e52b0a55f7686d50caf28ad6e7c
# Parent ff7c5a791ed58fbd9f5fd2db12b5a1b58fd11c4c
# Parent 98c6c36ac4443ce7f95c87eb317bf13d868e14e0
Merge
diff -r ff7c5a791ed5 -r fdea4a967bc7 buildconfigs/Rules.mk
--- a/buildconfigs/Rules.mk Fri Oct 21 19:58:39 2005
+++ b/buildconfigs/Rules.mk Mon Oct 24 15:08:13 2005
@@ -80,10 +80,12 @@
rm -f patches/*/.makedep
ref-%/.valid-ref: pristine-%/.valid-pristine
+ set -e
rm -rf $(@D)
cp -al $(<D) $(@D)
- ([ -d patches/$* ] && \
- for i in patches/$*/*.patch ; do ( cd $(@D) ; patch -p1 <../$$i ||
exit 1 ) ; done) || true
+ if [ -d patches/$* ] ; then \
+ for i in patches/$*/*.patch ; do ( cd $(@D) ; patch -p1 <../$$i ||
exit 1 ) ; done ; \
+ fi
touch $@ # update timestamp to avoid rebuild
endif
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c Mon Oct 24
15:08:13 2005
@@ -94,7 +94,7 @@
irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
- u32 l1, l2;
+ unsigned long l1, l2;
unsigned int l1i, l2i, port;
irqreturn_t (*handler)(int, void *, struct pt_regs *);
shared_info_t *s = HYPERVISOR_shared_info;
@@ -108,14 +108,14 @@
while ( l1 != 0 )
{
l1i = __ffs(l1);
- l1 &= ~(1 << l1i);
+ l1 &= ~(1UL << l1i);
while ( (l2 = s->evtchn_pending[l1i] & ~s->evtchn_mask[l1i]) != 0 )
{
l2i = __ffs(l2);
- l2 &= ~(1 << l2i);
+ l2 &= ~(1UL << l2i);
- port = (l1i << 5) + l2i;
+ port = (l1i * BITS_PER_LONG) + l2i;
if ( (handler = evtchns[port].handler) != NULL )
{
clear_evtchn(port);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32
--- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32 Fri Oct
21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32 Mon Oct
24 15:08:13 2005
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.12-xen
-# Wed Aug 3 10:04:25 2005
+# Linux kernel version: 2.6.12-xen0
+# Sat Oct 15 00:13:28 2005
#
CONFIG_XEN=y
CONFIG_ARCH_XEN=y
@@ -151,17 +151,15 @@
# CONFIG_REGPARM is not set
CONFIG_X86_LOCAL_APIC=y
CONFIG_X86_IO_APIC=y
-# CONFIG_HOTPLUG_CPU is not set
+CONFIG_HOTPLUG_CPU=y
#
# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
#
CONFIG_PCI=y
-# CONFIG_PCI_GOBIOS is not set
# CONFIG_PCI_GOMMCONFIG is not set
# CONFIG_PCI_GODIRECT is not set
CONFIG_PCI_GOANY=y
-CONFIG_PCI_BIOS=y
CONFIG_PCI_DIRECT=y
CONFIG_PCI_MMCONFIG=y
# CONFIG_PCIEPORTBUS is not set
@@ -199,8 +197,6 @@
#
CONFIG_HOTPLUG_PCI=m
CONFIG_HOTPLUG_PCI_FAKE=m
-# CONFIG_HOTPLUG_PCI_COMPAQ is not set
-# CONFIG_HOTPLUG_PCI_IBM is not set
# CONFIG_HOTPLUG_PCI_ACPI is not set
CONFIG_HOTPLUG_PCI_CPCI=y
CONFIG_HOTPLUG_PCI_CPCI_ZT5550=m
@@ -2667,6 +2663,7 @@
CONFIG_ACPI_VIDEO=m
CONFIG_ACPI_FAN=m
CONFIG_ACPI_PROCESSOR=m
+# CONFIG_ACPI_HOTPLUG_CPU is not set
CONFIG_ACPI_THERMAL=m
CONFIG_ACPI_ASUS=m
CONFIG_ACPI_IBM=m
@@ -2694,7 +2691,7 @@
CONFIG_EXT3_FS_SECURITY=y
CONFIG_JBD=m
# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=m
+CONFIG_FS_MBCACHE=y
CONFIG_REISERFS_FS=m
# CONFIG_REISERFS_CHECK is not set
# CONFIG_REISERFS_PROC_INFO is not set
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile Mon Oct 24
15:08:13 2005
@@ -27,7 +27,7 @@
c-obj-$(CONFIG_X86_CPUID) += cpuid.o
obj-$(CONFIG_MICROCODE) += microcode.o
c-obj-$(CONFIG_APM) += apm.o
-obj-$(CONFIG_X86_SMP) += smp.o smpboot.o
+obj-$(CONFIG_X86_SMP) += smp.o
#obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
obj-$(CONFIG_X86_MPPARSE) += mpparse.o
obj-$(CONFIG_X86_LOCAL_APIC) += apic.o
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S Mon Oct 24 15:08:13 2005
@@ -40,7 +40,7 @@
ENTRY(startup_32)
movl %esi,xen_start_info
-#ifdef CONFIG_SMP
+#if 0
ENTRY(startup_32_smp)
#endif /* CONFIG_SMP */
@@ -78,7 +78,7 @@
movl %eax,%gs
cld # gcc2 wants the direction flag cleared at all
times
-#ifdef CONFIG_SMP
+#if 0
movb ready, %cl
cmpb $1,%cl
je 1f # the first CPU calls start_kernel
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/i386/kernel/i386_ksyms.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/i386_ksyms.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/i386_ksyms.c Mon Oct 24
15:08:13 2005
@@ -136,9 +136,6 @@
#endif
#ifdef CONFIG_SMP
-EXPORT_SYMBOL(cpu_data);
-EXPORT_SYMBOL(cpu_online_map);
-EXPORT_SYMBOL(cpu_callout_map);
EXPORT_SYMBOL(__write_lock_failed);
EXPORT_SYMBOL(__read_lock_failed);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c Mon Oct 24
15:08:13 2005
@@ -112,44 +112,6 @@
}
}
-#ifdef CONFIG_HOTPLUG_CPU
-#include <asm/nmi.h>
-#ifdef CONFIG_SMP
-extern void smp_suspend(void);
-extern void smp_resume(void);
-#endif
-/* We don't actually take CPU down, just spin without interrupts. */
-static inline void play_dead(void)
-{
- /* Death loop */
- while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE)
- HYPERVISOR_sched_op(SCHEDOP_yield, 0);
-
- __flush_tlb_all();
- /*
- * Restore IPI/IRQ mappings before marking online to prevent
- * race between pending interrupts and restoration of handler.
- */
-#ifdef CONFIG_SMP
- local_irq_enable(); /* XXX Needed for smp_resume(). Clean me up. */
- smp_resume();
-#endif
- cpu_set(smp_processor_id(), cpu_online_map);
-}
-#else
-static inline void play_dead(void)
-{
- BUG();
-}
-#endif /* CONFIG_HOTPLUG_CPU */
-
-void cpu_restore(void)
-{
- play_dead();
- local_irq_enable();
- cpu_idle();
-}
-
/*
* The idle thread. There's no useful work to be
* done, so just try to conserve power and have a
@@ -158,7 +120,9 @@
*/
void cpu_idle (void)
{
+#if defined(CONFIG_HOTPLUG_CPU)
int cpu = _smp_processor_id();
+#endif
/* endless idle loop with no priority at all */
while (1) {
@@ -168,23 +132,12 @@
__get_cpu_var(cpu_idle_state) = 0;
rmb();
+#if defined(CONFIG_HOTPLUG_CPU)
if (cpu_is_offline(cpu)) {
- local_irq_disable();
-#ifdef CONFIG_SMP
- smp_suspend();
-#endif
-#if defined(CONFIG_XEN) && defined(CONFIG_HOTPLUG_CPU)
- /* Ack it. From this point on until
- we get woken up, we're not allowed
- to take any locks. In particular,
- don't printk. */
- __get_cpu_var(cpu_state) = CPU_DEAD;
- /* Tell hypervisor to take vcpu down. */
HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL);
-#endif
- play_dead();
local_irq_enable();
}
+#endif
__get_cpu_var(irq_stat).idle_timestamp = jiffies;
xen_idle();
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Mon Oct 24 15:08:13 2005
@@ -939,6 +939,8 @@
if ( xen_override_max_pfn < xen_start_info->nr_pages )
xen_override_max_pfn = xen_start_info->nr_pages;
max_pfn = xen_override_max_pfn;
+ /* 8MB slack, to make up for address space allocations in backends. */
+ max_pfn += 8 << (20 - PAGE_SHIFT);
}
#endif /* XEN */
@@ -1638,39 +1640,17 @@
#endif
/* Make sure we have a correctly sized P->M table. */
- if (max_pfn != xen_start_info->nr_pages) {
- phys_to_machine_mapping = alloc_bootmem_low_pages(
- max_pfn * sizeof(unsigned long));
-
- if (max_pfn > xen_start_info->nr_pages) {
- /* set to INVALID_P2M_ENTRY */
- memset(phys_to_machine_mapping, ~0,
- max_pfn * sizeof(unsigned long));
- memcpy(phys_to_machine_mapping,
- (unsigned long *)xen_start_info->mfn_list,
- xen_start_info->nr_pages * sizeof(unsigned
long));
- } else {
- struct xen_memory_reservation reservation = {
- .extent_start = (unsigned long
*)xen_start_info->mfn_list + max_pfn,
- .nr_extents = xen_start_info->nr_pages -
max_pfn,
- .extent_order = 0,
- .domid = DOMID_SELF
- };
-
- memcpy(phys_to_machine_mapping,
- (unsigned long *)xen_start_info->mfn_list,
- max_pfn * sizeof(unsigned long));
- BUG_ON(HYPERVISOR_memory_op(
- XENMEM_decrease_reservation,
- &reservation) !=
- (xen_start_info->nr_pages - max_pfn));
- }
- free_bootmem(
- __pa(xen_start_info->mfn_list),
- PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
- sizeof(unsigned long))));
- }
-
+ phys_to_machine_mapping = alloc_bootmem_low_pages(
+ max_pfn * sizeof(unsigned long));
+ memset(phys_to_machine_mapping, ~0,
+ max_pfn * sizeof(unsigned long));
+ memcpy(phys_to_machine_mapping,
+ (unsigned long *)xen_start_info->mfn_list,
+ xen_start_info->nr_pages * sizeof(unsigned long));
+ free_bootmem(
+ __pa(xen_start_info->mfn_list),
+ PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
+ sizeof(unsigned long))));
/*
* Initialise the list of the frames that specify the list of
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c Mon Oct 24 15:08:13 2005
@@ -122,7 +122,8 @@
static u64 processed_system_time; /* System time (ns) at last processing. */
static DEFINE_PER_CPU(u64, processed_system_time);
-#define NS_PER_TICK (1000000000ULL/HZ)
+/* Must be signed, as it's compared with s64 quantities which can be -ve. */
+#define NS_PER_TICK (1000000000LL/HZ)
static inline void __normalize_time(time_t *sec, s64 *nsec)
{
@@ -235,9 +236,9 @@
/* Adjust wall-clock time base based on wall_jiffies ticks. */
wc_nsec = processed_system_time;
- wc_nsec += (u64)sec * 1000000000ULL;
- wc_nsec += (u64)nsec;
- wc_nsec -= (jiffies - wall_jiffies) * (u64)(NSEC_PER_SEC / HZ);
+ wc_nsec += sec * (u64)NSEC_PER_SEC;
+ wc_nsec += nsec;
+ wc_nsec -= (jiffies - wall_jiffies) * (u64)NS_PER_TICK;
/* Split wallclock base into seconds and nanoseconds. */
tmp = wc_nsec;
@@ -437,7 +438,7 @@
* be stale, so we can retry with fresh ones.
*/
for ( ; ; ) {
- nsec = (s64)tv->tv_nsec - (s64)get_nsec_offset(shadow);
+ nsec = tv->tv_nsec - get_nsec_offset(shadow);
if (time_values_up_to_date(cpu))
break;
get_time_values_from_xen();
@@ -558,7 +559,7 @@
}
while (!time_values_up_to_date(cpu));
- if (unlikely(delta < (s64)-1000000) || unlikely(delta_cpu < 0)) {
+ if (unlikely(delta < -1000000LL) || unlikely(delta_cpu < 0)) {
printk("Timer ISR/%d: Time went backwards: "
"delta=%lld cpu_delta=%lld shadow=%lld "
"off=%lld processed=%lld cpu_processed=%lld\n",
@@ -784,7 +785,7 @@
rdtscll(vxtime.last_tsc);
#endif
- per_cpu(timer_irq, 0) = bind_virq_to_irq(VIRQ_TIMER);
+ per_cpu(timer_irq, 0) = bind_virq_to_irq(VIRQ_TIMER, 0);
(void)setup_irq(per_cpu(timer_irq, 0), &irq_timer);
}
@@ -802,7 +803,7 @@
* but that's ok: we'll just end up with a shorter timeout. */
if (delta < 1)
delta = 1;
- st = processed_system_time + ((u64)delta * NS_PER_TICK);
+ st = processed_system_time + (delta * (u64)NS_PER_TICK);
} while (read_seqretry(&xtime_lock, seq));
return st;
@@ -851,21 +852,12 @@
#ifdef CONFIG_SMP
static char timer_name[NR_CPUS][15];
-void local_setup_timer_irq(void)
-{
- int cpu = smp_processor_id();
-
- if (cpu == 0)
- return;
- per_cpu(timer_irq, cpu) = bind_virq_to_irq(VIRQ_TIMER);
- sprintf(timer_name[cpu], "timer%d", cpu);
- BUG_ON(request_irq(per_cpu(timer_irq, cpu), timer_interrupt,
- SA_INTERRUPT, timer_name[cpu], NULL));
-}
-
-void local_setup_timer(void)
-{
- int seq, cpu = smp_processor_id();
+
+void local_setup_timer(unsigned int cpu)
+{
+ int seq;
+
+ BUG_ON(cpu == 0);
do {
seq = read_seqbegin(&xtime_lock);
@@ -873,17 +865,17 @@
per_cpu(shadow_time, cpu).system_timestamp;
} while (read_seqretry(&xtime_lock, seq));
- local_setup_timer_irq();
-}
-
-void local_teardown_timer_irq(void)
-{
- int cpu = smp_processor_id();
-
- if (cpu == 0)
- return;
+ per_cpu(timer_irq, cpu) = bind_virq_to_irq(VIRQ_TIMER, cpu);
+ sprintf(timer_name[cpu], "timer%d", cpu);
+ BUG_ON(request_irq(per_cpu(timer_irq, cpu), timer_interrupt,
+ SA_INTERRUPT, timer_name[cpu], NULL));
+}
+
+void local_teardown_timer(unsigned int cpu)
+{
+ BUG_ON(cpu == 0);
free_irq(per_cpu(timer_irq, cpu), NULL);
- unbind_virq_from_irq(VIRQ_TIMER);
+ unbind_virq_from_irq(VIRQ_TIMER, cpu);
}
#endif
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c Mon Oct 24 15:08:13 2005
@@ -123,9 +123,18 @@
return __direct_remap_pfn_range(
vma->vm_mm, address, mfn, size, prot, domid);
}
-
EXPORT_SYMBOL(direct_remap_pfn_range);
+int direct_kernel_remap_pfn_range(unsigned long address,
+ unsigned long mfn,
+ unsigned long size,
+ pgprot_t prot,
+ domid_t domid)
+{
+ return __direct_remap_pfn_range(
+ &init_mm, address, mfn, size, prot, domid);
+}
+EXPORT_SYMBOL(direct_kernel_remap_pfn_range);
/* FIXME: This is horribly broken on PAE */
static int lookup_pte_fn(
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/xen/kernel/Makefile Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/Makefile Mon Oct 24 15:08:13 2005
@@ -15,4 +15,4 @@
obj-$(CONFIG_PROC_FS) += xen_proc.o
obj-$(CONFIG_NET) += skbuff.o
-obj-$(CONFIG_SMP) += smp.o
+obj-$(CONFIG_SMP) += smp.o smpboot.o
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c Mon Oct 24 15:08:13 2005
@@ -42,6 +42,7 @@
#include <asm-xen/xen-public/physdev.h>
#include <asm/hypervisor.h>
#include <asm-xen/evtchn.h>
+#include <linux/mc146818rtc.h> /* RTC_IRQ */
/*
* This lock protects updates to the following mapping and reference-count
@@ -70,8 +71,8 @@
#ifdef CONFIG_SMP
-static u8 cpu_evtchn[NR_EVENT_CHANNELS];
-static u32 cpu_evtchn_mask[NR_CPUS][NR_EVENT_CHANNELS/32];
+static u8 cpu_evtchn[NR_EVENT_CHANNELS];
+static unsigned long cpu_evtchn_mask[NR_CPUS][NR_EVENT_CHANNELS/BITS_PER_LONG];
#define active_evtchns(cpu,sh,idx) \
((sh)->evtchn_pending[idx] & \
@@ -136,7 +137,7 @@
/* NB. Interrupts are disabled on entry. */
asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
{
- u32 l1, l2;
+ unsigned long l1, l2;
unsigned int l1i, l2i, port;
int irq, cpu = smp_processor_id();
shared_info_t *s = HYPERVISOR_shared_info;
@@ -148,13 +149,13 @@
l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
while (l1 != 0) {
l1i = __ffs(l1);
- l1 &= ~(1 << l1i);
+ l1 &= ~(1UL << l1i);
while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
l2i = __ffs(l2);
- l2 &= ~(1 << l2i);
+ l2 &= ~(1UL << l2i);
- port = (l1i << 5) + l2i;
+ port = (l1i * BITS_PER_LONG) + l2i;
if ((irq = evtchn_to_irq[port]) != -1)
do_IRQ(irq, regs);
else
@@ -178,11 +179,10 @@
return irq;
}
-int bind_virq_to_irq(int virq)
+int bind_virq_to_irq(int virq, int cpu)
{
evtchn_op_t op = { .cmd = EVTCHNOP_bind_virq };
int evtchn, irq;
- int cpu = smp_processor_id();
spin_lock(&irq_mapping_update_lock);
@@ -209,10 +209,9 @@
}
EXPORT_SYMBOL(bind_virq_to_irq);
-void unbind_virq_from_irq(int virq)
+void unbind_virq_from_irq(int virq, int cpu)
{
evtchn_op_t op = { .cmd = EVTCHNOP_close };
- int cpu = smp_processor_id();
int irq = per_cpu(virq_to_irq, cpu)[virq];
int evtchn = irq_to_evtchn[irq];
@@ -240,11 +239,10 @@
}
EXPORT_SYMBOL(unbind_virq_from_irq);
-int bind_ipi_to_irq(int ipi)
+int bind_ipi_to_irq(int ipi, int cpu)
{
evtchn_op_t op = { .cmd = EVTCHNOP_bind_ipi };
int evtchn, irq;
- int cpu = smp_processor_id();
spin_lock(&irq_mapping_update_lock);
@@ -272,10 +270,9 @@
}
EXPORT_SYMBOL(bind_ipi_to_irq);
-void unbind_ipi_from_irq(int ipi)
+void unbind_ipi_from_irq(int ipi, int cpu)
{
evtchn_op_t op = { .cmd = EVTCHNOP_close };
- int cpu = smp_processor_id();
int evtchn = per_cpu(ipi_to_evtchn, cpu)[ipi];
int irq = evtchn_to_irq[evtchn];
@@ -748,6 +745,13 @@
{
irq_bindcount[pirq_to_irq(i)] = 1;
+#ifdef RTC_IRQ
+ /* If not domain 0, force our RTC driver to fail its probe. */
+ if ((i == RTC_IRQ) &&
+ !(xen_start_info->flags & SIF_INITDOMAIN))
+ continue;
+#endif
+
irq_desc[pirq_to_irq(i)].status = IRQ_DISABLED;
irq_desc[pirq_to_irq(i)].action = 0;
irq_desc[pirq_to_irq(i)].depth = 1;
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c Mon Oct 24 15:08:13 2005
@@ -26,7 +26,6 @@
// the distinction when we return the reason code to them.
#define SHUTDOWN_HALT 4
-
void machine_restart(char * __unused)
{
/* We really want to get pending console data out before we die. */
@@ -60,6 +59,8 @@
/* Ignore multiple shutdown requests. */
static int shutting_down = SHUTDOWN_INVALID;
+static void __shutdown_handler(void *unused);
+static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
#ifndef CONFIG_HOTPLUG_CPU
#define cpu_down(x) (-EOPNOTSUPP)
@@ -243,40 +244,46 @@
return 0;
}
-static struct task_struct *kthread_create_on_cpu(int (*f)(void *arg),
- void *arg,
- const char *name,
- int cpu)
+static int kthread_create_on_cpu(int (*f)(void *arg),
+ void *arg,
+ const char *name,
+ int cpu)
{
struct task_struct *p;
p = kthread_create(f, arg, name);
+ if (IS_ERR(p))
+ return PTR_ERR(p);
kthread_bind(p, cpu);
wake_up_process(p);
- return p;
+ return 0;
}
static void __shutdown_handler(void *unused)
{
int err;
- if (shutting_down != SHUTDOWN_SUSPEND) {
+ if (shutting_down != SHUTDOWN_SUSPEND)
err = kernel_thread(shutdown_process, NULL,
CLONE_FS | CLONE_FILES);
- if ( err < 0 )
- printk(KERN_ALERT "Error creating shutdown "
- "process!\n");
- } else {
- kthread_create_on_cpu(__do_suspend, NULL, "suspender", 0);
+ else
+ err = kthread_create_on_cpu(__do_suspend, NULL, "suspend", 0);
+
+ if ( err < 0 ) {
+ printk(KERN_WARNING "Error creating shutdown process (%d): "
+ "retrying...\n", -err);
+ schedule_delayed_work(&shutdown_work, HZ/2);
}
}
static void shutdown_handler(struct xenbus_watch *watch,
const char **vec, unsigned int len)
{
- static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
char *str;
struct xenbus_transaction *xbt;
int err;
+
+ if (shutting_down != SHUTDOWN_INVALID)
+ goto out;
again:
xbt = xenbus_transaction_start();
@@ -312,6 +319,7 @@
kfree(str);
+ out:
if (shutting_down != SHUTDOWN_INVALID)
schedule_work(&shutdown_work);
}
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile Mon Oct 24
15:08:13 2005
@@ -25,7 +25,7 @@
c-obj-$(CONFIG_X86_MSR) += msr.o
obj-$(CONFIG_MICROCODE) += microcode.o
obj-$(CONFIG_X86_CPUID) += cpuid.o
-obj-$(CONFIG_SMP) += smp.o smpboot.o
+obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_X86_LOCAL_APIC) += apic.o
c-obj-$(CONFIG_X86_LOCAL_APIC) += nmi.o
obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c Mon Oct 24
15:08:13 2005
@@ -519,7 +519,7 @@
e820_print_map(who);
}
-#else /* CONFIX_XEN */
+#else /* CONFIG_XEN */
extern unsigned long xen_override_max_pfn;
extern union xen_start_info_union xen_start_info_union;
@@ -528,10 +528,13 @@
{
unsigned long max_end_pfn = xen_start_info->nr_pages;
- if ( xen_override_max_pfn < max_end_pfn)
+ if ( xen_override_max_pfn < max_end_pfn)
xen_override_max_pfn = max_end_pfn;
-
- return xen_override_max_pfn;
+
+ /* 8MB slack, to make up for address space allocations in backends. */
+ xen_override_max_pfn += 8 << (20 - PAGE_SHIFT);
+
+ return xen_override_max_pfn;
}
void __init e820_reserve_resources(void)
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Mon Oct 24
15:08:13 2005
@@ -429,7 +429,7 @@
static void __init contig_initmem_init(void)
{
unsigned long bootmap_size = init_bootmem(start_pfn, end_pfn);
- free_bootmem(0, end_pfn << PAGE_SHIFT);
+ free_bootmem(0, xen_start_info->nr_pages << PAGE_SHIFT);
reserve_bootmem(HIGH_MEMORY,
(PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE-1)
- HIGH_MEMORY);
@@ -733,20 +733,22 @@
#ifdef CONFIG_XEN
{
int i, j, k, fpp;
+
/* Make sure we have a large enough P->M table. */
- if (end_pfn > xen_start_info->nr_pages) {
- phys_to_machine_mapping = alloc_bootmem(
- end_pfn * sizeof(unsigned long));
- memset(phys_to_machine_mapping, ~0,
- end_pfn * sizeof(unsigned long));
- memcpy(phys_to_machine_mapping,
- (unsigned long *)xen_start_info->mfn_list,
- xen_start_info->nr_pages * sizeof(unsigned
long));
- free_bootmem(
- __pa(xen_start_info->mfn_list),
- PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
- sizeof(unsigned long))));
- }
+ phys_to_machine_mapping = alloc_bootmem(
+ end_pfn * sizeof(unsigned long));
+ memset(phys_to_machine_mapping, ~0,
+ end_pfn * sizeof(unsigned long));
+ memcpy(phys_to_machine_mapping,
+ (unsigned long *)xen_start_info->mfn_list,
+ xen_start_info->nr_pages * sizeof(unsigned long));
+ free_bootmem(
+ __pa(xen_start_info->mfn_list),
+ PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
+ sizeof(unsigned long))));
+ make_pages_readonly((void *)xen_start_info->mfn_list,
+ PFN_UP(xen_start_info->nr_pages *
+ sizeof(unsigned long)));
/*
* Initialise the list of the frames that specify the list of
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c Mon Oct 24
15:08:13 2005
@@ -113,14 +113,11 @@
EXPORT_SYMBOL(cpu_pda);
#ifdef CONFIG_SMP
-EXPORT_SYMBOL(cpu_data);
-EXPORT_SYMBOL(cpu_online_map);
EXPORT_SYMBOL(__write_lock_failed);
EXPORT_SYMBOL(__read_lock_failed);
EXPORT_SYMBOL(synchronize_irq);
EXPORT_SYMBOL(smp_call_function);
-EXPORT_SYMBOL(cpu_callout_map);
#endif
#ifdef CONFIG_VT
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Mon Oct 24
15:08:13 2005
@@ -502,7 +502,7 @@
.extent_order = 0,
.domid = DOMID_SELF
};
- set_pte(pte, __pte_ma(0));
+ set_pte_at(&init_mm, addr, pte, __pte_ma(0));
phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
INVALID_P2M_ENTRY;
BUG_ON(HYPERVISOR_memory_op(
@@ -521,10 +521,9 @@
scrub_pages(vstart, 1 << order);
+ balloon_lock(flags);
BUG_ON(generic_page_range(
&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
-
- balloon_lock(flags);
current_pages -= 1UL << order;
balloon_unlock(flags);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Mon Oct 24
15:08:13 2005
@@ -494,10 +494,6 @@
int i;
struct page *page;
- if (!(xen_start_info->flags & SIF_INITDOMAIN) &&
- !(xen_start_info->flags & SIF_BLK_BE_DOMAIN))
- return 0;
-
blkif_interface_init();
page = balloon_alloc_empty_page_range(MMAP_PAGES);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Mon Oct 24
15:08:13 2005
@@ -725,21 +725,9 @@
.suspend = blkfront_suspend,
};
-static void __init init_blk_xenbus(void)
+static int __init xlblk_init(void)
{
xenbus_register_driver(&blkfront);
-}
-
-static int __init xlblk_init(void)
-{
- if ((xen_start_info->flags & SIF_INITDOMAIN) ||
- (xen_start_info->flags & SIF_BLK_BE_DOMAIN) )
- return 0;
-
- IPRINTK("Initialising virtual block device driver\n");
-
- init_blk_xenbus();
-
return 0;
}
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Mon Oct 24 15:08:13 2005
@@ -861,11 +861,7 @@
{
int i, j, err;
struct page *page;
-/*
- if ( !(xen_start_info->flags & SIF_INITDOMAIN) &&
- !(xen_start_info->flags & SIF_BLK_BE_DOMAIN) )
- return 0;
-*/
+
blkif_interface_init();
page = balloon_alloc_empty_page_range(MMAP_PAGES);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c Mon Oct 24
15:08:13 2005
@@ -768,7 +768,7 @@
#endif
if (xen_start_info->flags & SIF_INITDOMAIN) {
- xencons_priv_irq = bind_virq_to_irq(VIRQ_CONSOLE);
+ xencons_priv_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
(void)request_irq(xencons_priv_irq,
xencons_priv_interrupt, 0, "console", NULL);
} else {
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c Mon Oct 24
15:08:13 2005
@@ -34,14 +34,18 @@
{
int sent = 0;
struct xencons_interface *intf = xencons_interface();
+ XENCONS_RING_IDX cons, prod;
- while ((sent < len) &&
- (intf->out_prod - intf->out_cons) < sizeof(intf->out)) {
- intf->out[MASK_XENCONS_IDX(intf->out_prod, intf->out)] =
- data[sent];
- intf->out_prod++;
- sent++;
- }
+ cons = intf->out_cons;
+ prod = intf->out_prod;
+ mb();
+ BUG_ON((prod - cons) > sizeof(intf->out));
+
+ while ((sent < len) && ((prod - cons) < sizeof(intf->out)))
+ intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = data[sent++];
+
+ wmb();
+ intf->out_prod = prod;
/* Use evtchn: this is called early, before irq is set up. */
notify_remote_via_evtchn(xen_start_info->console_evtchn);
@@ -52,15 +56,22 @@
static irqreturn_t handle_input(int irq, void *unused, struct pt_regs *regs)
{
struct xencons_interface *intf = xencons_interface();
+ XENCONS_RING_IDX cons, prod;
- while (intf->in_cons != intf->in_prod) {
+ cons = intf->in_cons;
+ prod = intf->in_prod;
+ mb();
+ BUG_ON((prod - cons) > sizeof(intf->in));
+
+ while (cons != prod) {
if (xencons_receiver != NULL)
xencons_receiver(
- intf->in + MASK_XENCONS_IDX(intf->in_cons,
- intf->in),
+ intf->in + MASK_XENCONS_IDX(cons++, intf->in),
1, regs);
- intf->in_cons++;
}
+
+ wmb();
+ intf->in_cons = cons;
return IRQ_HANDLED;
}
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Mon Oct 24
15:08:13 2005
@@ -58,7 +58,7 @@
dev = alloc_netdev(sizeof(netif_t), name, ether_setup);
if (dev == NULL) {
DPRINTK("Could not create netif: out of memory\n");
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
netif = netdev_priv(dev);
@@ -104,7 +104,7 @@
DPRINTK("Could not register new net device %s: err=%d\n",
dev->name, err);
free_netdev(dev);
- return NULL;
+ return ERR_PTR(err);
}
DPRINTK("Successfully created netif\n");
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Mon Oct 24
15:08:13 2005
@@ -781,12 +781,6 @@
int i;
struct page *page;
- if (!(xen_start_info->flags & SIF_NET_BE_DOMAIN) &&
- !(xen_start_info->flags & SIF_INITDOMAIN))
- return 0;
-
- IPRINTK("Initialising Xen netif backend.\n");
-
/* We can increase reservation by this much in net_rx_action(). */
balloon_update_driver_allowance(NETIF_RX_RING_SIZE);
@@ -817,7 +811,7 @@
netif_xenbus_init();
- (void)request_irq(bind_virq_to_irq(VIRQ_DEBUG),
+ (void)request_irq(bind_virq_to_irq(VIRQ_DEBUG, 0),
netif_be_dbg, SA_SHIRQ,
"net-be-dbg", &netif_be_dbg);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Mon Oct 24 15:08:13 2005
@@ -28,10 +28,6 @@
netif_t *netif;
long int frontend_id;
-#if 0
- long int pdev;
- long int readonly;
-#endif
/* watch back end for changes */
struct xenbus_watch backend_watch;
@@ -155,14 +151,6 @@
return;
}
-#if 0
- err = vbd_create(be->netif, handle, be->pdev, be->readonly);
- if (err) {
- xenbus_dev_error(dev, err, "creating vbd structure");
- return;
- }
-#endif
-
kobject_hotplug(&dev->dev.kobj, KOBJ_ONLINE);
/* Pass in NULL node to skip exist test. */
@@ -173,33 +161,26 @@
static int netback_hotplug(struct xenbus_device *xdev, char **envp,
int num_envp, char *buffer, int buffer_size)
{
- struct backend_info *be;
- netif_t *netif;
- char **key, *val;
+ struct backend_info *be = xdev->data;
+ netif_t *netif = be->netif;
int i = 0, length = 0;
- static char *env_vars[] = { "script", "domain", "mac", "bridge", "ip",
- NULL };
-
- be = xdev->data;
- netif = be->netif;
+
+ char *val = xenbus_read(NULL, xdev->nodename, "script", NULL);
+ if (IS_ERR(val)) {
+ int err = PTR_ERR(val);
+ xenbus_dev_error(xdev, err, "reading script");
+ return err;
+ }
+ else {
+ add_hotplug_env_var(envp, num_envp, &i,
+ buffer, buffer_size, &length,
+ "script=%s", val);
+ kfree(val);
+ }
add_hotplug_env_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"vif=%s", netif->dev->name);
-
- key = env_vars;
- while (*key != NULL) {
- val = xenbus_read(NULL, xdev->nodename, *key, NULL);
- if (!IS_ERR(val)) {
- char buf[strlen(*key) + 4];
- sprintf(buf, "%s=%%s", *key);
- add_hotplug_env_var(envp, num_envp, &i,
- buffer, buffer_size, &length,
- buf, val);
- kfree(val);
- }
- key++;
- }
envp[i] = NULL;
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Mon Oct 24
15:08:13 2005
@@ -25,8 +25,6 @@
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/tlb.h>
-#include <asm-xen/xen-public/xen.h>
-#include <asm/hypervisor.h>
#include <asm-xen/linux-public/privcmd.h>
#include <asm/hypervisor.h>
#include <asm-xen/xen-public/xen.h>
@@ -219,41 +217,6 @@
}
break;
- case IOCTL_PRIVCMD_INITDOMAIN_STORE: {
- extern int do_xenbus_probe(void*);
- unsigned long page;
-
- if (xen_start_info->store_evtchn != 0) {
- ret = xen_start_info->store_mfn;
- break;
- }
-
- /* Allocate page. */
- page = get_zeroed_page(GFP_KERNEL);
- if (!page) {
- ret = -ENOMEM;
- break;
- }
-
- /* We don't refcnt properly, so set reserved on page.
- * (this allocation is permanent) */
- SetPageReserved(virt_to_page(page));
-
- /* Initial connect. Setup channel and page. */
- xen_start_info->store_evtchn = data;
- xen_start_info->store_mfn =
- pfn_to_mfn(virt_to_phys((void *)page) >>
- PAGE_SHIFT);
- ret = xen_start_info->store_mfn;
-
- /*
- ** Complete initialization of xenbus (viz. set up the
- ** connection to xenstored now that it has started).
- */
- kthread_run(do_xenbus_probe, NULL, "xenbus_probe");
- }
- break;
-
default:
ret = -EINVAL;
break;
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Mon Oct 24
15:08:13 2005
@@ -17,6 +17,7 @@
#include <linux/types.h>
#include <linux/list.h>
#include <linux/miscdevice.h>
+#include <linux/poll.h>
#include <asm/uaccess.h>
#include <asm-xen/xenbus.h>
#include <asm-xen/xen-public/grant_table.h>
@@ -680,9 +681,14 @@
}
static unsigned int
-vtpm_op_poll(struct file *file, struct poll_table_struct *pst)
-{
- return 0;
+vtpm_op_poll(struct file *file, struct poll_table_struct *pts)
+{
+ unsigned int flags = POLLOUT | POLLWRNORM;
+ poll_wait(file, &dataex.wait_queue, pts);
+ if (!list_empty(&dataex.pending_pak)) {
+ flags |= POLLIN | POLLRDNORM;
+ }
+ return flags;
}
static struct file_operations vtpm_ops = {
@@ -1070,11 +1076,6 @@
tpmback_init(void)
{
int rc;
- if (!(xen_start_info->flags & SIF_TPM_BE_DOMAIN) &&
- !(xen_start_info->flags & SIF_INITDOMAIN)) {
- printk(KERN_ALERT "Neither TPM-BE Domain nor INIT domain!\n");
- return 0;
- }
if ((rc = misc_register(&ibmvtpms_miscdevice)) != 0) {
printk(KERN_ALERT "Could not register misc device for TPM
BE.\n");
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Mon Oct 24
15:08:13 2005
@@ -39,6 +39,7 @@
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/tpmfe.h>
+#include <linux/err.h>
#include <asm/semaphore.h>
#include <asm/io.h>
@@ -372,7 +373,7 @@
info->watch.callback = watch_for_status;
err = register_xenbus_watch(&info->watch);
if (err) {
- message = "registering watch on backend";
+ xenbus_dev_error(dev, err, "registering watch on backend");
goto destroy_tpmring;
}
@@ -398,6 +399,8 @@
int err;
struct tpmfront_info *info;
int handle;
+ int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1;
+ const char *vec[len];
err = xenbus_scanf(NULL, dev->nodename,
"handle", "%i", &handle);
@@ -426,6 +429,10 @@
dev->data = NULL;
return err;
}
+
+ vec[XS_WATCH_PATH] = info->watch.node;
+ vec[XS_WATCH_TOKEN] = NULL;
+ watch_for_status(&info->watch, vec, len);
return 0;
}
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Mon Oct 24
15:08:13 2005
@@ -33,164 +33,139 @@
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/err.h>
+#include <asm-xen/xenbus.h>
#include "xenbus_comms.h"
-#define RINGBUF_DATASIZE ((PAGE_SIZE / 2) - sizeof(struct ringbuf_head))
-struct ringbuf_head
-{
- u32 write; /* Next place to write to */
- u32 read; /* Next place to read from */
- u8 flags;
- char buf[0];
-} __attribute__((packed));
-
-static int xenbus_irq;
+static int xenbus_irq = 0;
+
+extern void xenbus_probe(void *);
+extern int xenstored_ready;
+static DECLARE_WORK(probe_work, xenbus_probe, NULL);
DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
-static inline struct ringbuf_head *outbuf(void)
+static inline struct xenstore_domain_interface *xenstore_domain_interface(void)
{
return mfn_to_virt(xen_start_info->store_mfn);
}
-static inline struct ringbuf_head *inbuf(void)
-{
- return mfn_to_virt(xen_start_info->store_mfn) + PAGE_SIZE/2;
-}
-
static irqreturn_t wake_waiting(int irq, void *unused, struct pt_regs *regs)
{
+ if(unlikely(xenstored_ready == 0)) {
+ xenstored_ready = 1;
+ schedule_work(&probe_work);
+ }
+
wake_up(&xb_waitq);
return IRQ_HANDLED;
}
-static int check_buffer(const struct ringbuf_head *h)
-{
- return (h->write < RINGBUF_DATASIZE && h->read < RINGBUF_DATASIZE);
-}
-
-/* We can't fill last byte: would look like empty buffer. */
-static void *get_output_chunk(const struct ringbuf_head *h,
- void *buf, u32 *len)
-{
- u32 read_mark;
-
- if (h->read == 0)
- read_mark = RINGBUF_DATASIZE - 1;
- else
- read_mark = h->read - 1;
-
- /* Here to the end of buffer, unless they haven't read some out. */
- *len = RINGBUF_DATASIZE - h->write;
- if (read_mark >= h->write)
- *len = read_mark - h->write;
- return buf + h->write;
-}
-
-static const void *get_input_chunk(const struct ringbuf_head *h,
- const void *buf, u32 *len)
-{
- /* Here to the end of buffer, unless they haven't written some. */
- *len = RINGBUF_DATASIZE - h->read;
- if (h->write >= h->read)
- *len = h->write - h->read;
- return buf + h->read;
-}
-
-static void update_output_chunk(struct ringbuf_head *h, u32 len)
-{
- h->write += len;
- if (h->write == RINGBUF_DATASIZE)
- h->write = 0;
-}
-
-static void update_input_chunk(struct ringbuf_head *h, u32 len)
-{
- h->read += len;
- if (h->read == RINGBUF_DATASIZE)
- h->read = 0;
-}
-
-static int output_avail(struct ringbuf_head *out)
-{
- unsigned int avail;
-
- get_output_chunk(out, out->buf, &avail);
- return avail != 0;
+static int check_indexes(XENSTORE_RING_IDX cons, XENSTORE_RING_IDX prod)
+{
+ return ((prod - cons) <= XENSTORE_RING_SIZE);
+}
+
+static void *get_output_chunk(XENSTORE_RING_IDX cons,
+ XENSTORE_RING_IDX prod,
+ char *buf, uint32_t *len)
+{
+ *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(prod);
+ if ((XENSTORE_RING_SIZE - (prod - cons)) < *len)
+ *len = XENSTORE_RING_SIZE - (prod - cons);
+ return buf + MASK_XENSTORE_IDX(prod);
+}
+
+static const void *get_input_chunk(XENSTORE_RING_IDX cons,
+ XENSTORE_RING_IDX prod,
+ const char *buf, uint32_t *len)
+{
+ *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(cons);
+ if ((prod - cons) < *len)
+ *len = prod - cons;
+ return buf + MASK_XENSTORE_IDX(cons);
}
int xb_write(const void *data, unsigned len)
{
- struct ringbuf_head h;
- struct ringbuf_head *out = outbuf();
-
- do {
+ struct xenstore_domain_interface *intf = xenstore_domain_interface();
+ XENSTORE_RING_IDX cons, prod;
+
+ while (len != 0) {
void *dst;
unsigned int avail;
- wait_event_interruptible(xb_waitq, output_avail(out));
-
+ wait_event_interruptible(xb_waitq,
+ (intf->req_prod - intf->req_cons) !=
+ XENSTORE_RING_SIZE);
+
+ /* Read indexes, then verify. */
+ cons = intf->req_cons;
+ prod = intf->req_prod;
mb();
- h = *out;
- if (!check_buffer(&h))
+ if (!check_indexes(cons, prod))
return -EIO;
- dst = get_output_chunk(&h, out->buf, &avail);
+ dst = get_output_chunk(cons, prod, intf->req, &avail);
if (avail == 0)
continue;
if (avail > len)
avail = len;
+
memcpy(dst, data, avail);
data += avail;
len -= avail;
- update_output_chunk(out, avail);
+
+ /* Other side must not see new header until data is there. */
+ wmb();
+ intf->req_prod += avail;
+
+ /* This implies mb() before other side sees interrupt. */
notify_remote_via_evtchn(xen_start_info->store_evtchn);
- } while (len != 0);
+ }
return 0;
}
-int xs_input_avail(void)
-{
- unsigned int avail;
- struct ringbuf_head *in = inbuf();
-
- get_input_chunk(in, in->buf, &avail);
- return avail != 0;
-}
-
int xb_read(void *data, unsigned len)
{
- struct ringbuf_head h;
- struct ringbuf_head *in = inbuf();
- int was_full;
+ struct xenstore_domain_interface *intf = xenstore_domain_interface();
+ XENSTORE_RING_IDX cons, prod;
while (len != 0) {
unsigned int avail;
const char *src;
- wait_event_interruptible(xb_waitq, xs_input_avail());
-
+ wait_event_interruptible(xb_waitq,
+ intf->rsp_cons != intf->rsp_prod);
+
+ /* Read indexes, then verify. */
+ cons = intf->rsp_cons;
+ prod = intf->rsp_prod;
mb();
- h = *in;
- if (!check_buffer(&h))
+ if (!check_indexes(cons, prod))
return -EIO;
- src = get_input_chunk(&h, in->buf, &avail);
+ src = get_input_chunk(cons, prod, intf->rsp, &avail);
if (avail == 0)
continue;
if (avail > len)
avail = len;
- was_full = !output_avail(&h);
+
+ /* We must read header before we read data. */
+ rmb();
memcpy(data, src, avail);
data += avail;
len -= avail;
- update_input_chunk(in, avail);
+
+ /* Other side must not see free space until we've copied out */
+ mb();
+ intf->rsp_cons += avail;
+
pr_debug("Finished read of %i bytes (%i to go)\n", avail, len);
- /* If it was full, tell them we've taken some. */
- if (was_full)
- notify_remote_via_evtchn(xen_start_info->store_evtchn);
+
+ /* Implies mb(): they will see new header. */
+ notify_remote_via_evtchn(xen_start_info->store_evtchn);
}
return 0;
@@ -203,10 +178,6 @@
if (xenbus_irq)
unbind_evtchn_from_irqhandler(xenbus_irq, &xb_waitq);
- xenbus_irq = 0;
-
- if (!xen_start_info->store_evtchn)
- return 0;
err = bind_evtchn_to_irqhandler(
xen_start_info->store_evtchn, wake_waiting,
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Mon Oct 24
15:08:13 2005
@@ -27,17 +27,28 @@
*/
#define DEBUG
-#include <asm/hypervisor.h>
-#include <asm-xen/xenbus.h>
-#include <asm-xen/balloon.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/fcntl.h>
-#include <stdarg.h>
+#include <linux/mm.h>
#include <linux/notifier.h>
+#include <linux/kthread.h>
+
+#include <asm/io.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/hypervisor.h>
+#include <asm-xen/xenbus.h>
+#include <asm-xen/xen_proc.h>
+#include <asm-xen/balloon.h>
+#include <asm-xen/evtchn.h>
+#include <asm-xen/linux-public/evtchn.h>
+
#include "xenbus_comms.h"
+
+extern struct semaphore xenwatch_mutex;
#define streq(a, b) (strcmp((a), (b)) == 0)
@@ -229,13 +240,18 @@
static int xenbus_register_driver_common(struct xenbus_driver *drv,
struct xen_bus_type *bus)
{
+ int ret;
+
drv->driver.name = drv->name;
drv->driver.bus = &bus->bus;
drv->driver.owner = drv->owner;
drv->driver.probe = xenbus_dev_probe;
drv->driver.remove = xenbus_dev_remove;
- return driver_register(&drv->driver);
+ down(&xenwatch_mutex);
+ ret = driver_register(&drv->driver);
+ up(&xenwatch_mutex);
+ return ret;
}
int xenbus_register_driver(struct xenbus_driver *drv)
@@ -627,15 +643,19 @@
bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
}
+
+/* A flag to determine if xenstored is 'ready' (i.e. has started) */
+int xenstored_ready = 0;
+
+
int register_xenstore_notifier(struct notifier_block *nb)
{
int ret = 0;
- if (xen_start_info->store_evtchn) {
+ if(xenstored_ready > 0)
ret = nb->notifier_call(nb, 0, NULL);
- } else {
+ else
notifier_chain_register(&xenstore_chain, nb);
- }
return ret;
}
@@ -647,22 +667,11 @@
}
EXPORT_SYMBOL(unregister_xenstore_notifier);
-/*
-** Called either from below xenbus_probe_init() initcall (for domUs)
-** or, for dom0, from a thread created in privcmd/privcmd.c (after
-** the user-space tools have invoked initDomainStore())
-*/
-int do_xenbus_probe(void *unused)
-{
- int err = 0;
-
- /* Initialize the interface to xenstore. */
- err = xs_init();
- if (err) {
- printk("XENBUS: Error initializing xenstore comms:"
- " %i\n", err);
- return err;
- }
+
+
+void xenbus_probe(void *unused)
+{
+ BUG_ON((xenstored_ready <= 0));
/* Enumerate devices in xenstore. */
xenbus_probe_devices(&xenbus_frontend);
@@ -675,27 +684,101 @@
/* Notify others that xenstore is up */
notifier_call_chain(&xenstore_chain, 0, 0);
- return 0;
-}
+ return;
+}
+
+
+static struct proc_dir_entry *xsd_mfn_intf;
+static struct proc_dir_entry *xsd_port_intf;
+
+
+static int xsd_mfn_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len;
+ len = sprintf(page, "%ld", xen_start_info->store_mfn);
+ *eof = 1;
+ return len;
+}
+
+static int xsd_port_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len;
+
+ len = sprintf(page, "%d", xen_start_info->store_evtchn);
+ *eof = 1;
+ return len;
+}
+
static int __init xenbus_probe_init(void)
{
- if (xen_init() < 0)
+ int err = 0;
+ /*
+ ** Domain0 doesn't have a store_evtchn or store_mfn yet.
+ */
+ int dom0 = (xen_start_info->store_evtchn == 0);
+
+ printk("xenbus_probe_init\n");
+
+ if (xen_init() < 0) {
+ printk("xen_init failed\n");
return -ENODEV;
-
+ }
+
+ /* Register ourselves with the kernel bus & device subsystems */
bus_register(&xenbus_frontend.bus);
bus_register(&xenbus_backend.bus);
device_register(&xenbus_frontend.dev);
device_register(&xenbus_backend.dev);
- /*
- ** Domain0 doesn't have a store_evtchn yet - this will
- ** be set up later by xend invoking initDomainStore()
- */
- if (!xen_start_info->store_evtchn)
- return 0;
-
- do_xenbus_probe(NULL);
+ if (dom0) {
+
+ unsigned long page;
+ evtchn_op_t op = { 0 };
+
+
+ /* Allocate page. */
+ page = get_zeroed_page(GFP_KERNEL);
+ if (!page)
+ return -ENOMEM;
+
+ /* We don't refcnt properly, so set reserved on page.
+ * (this allocation is permanent) */
+ SetPageReserved(virt_to_page(page));
+
+ xen_start_info->store_mfn =
+ pfn_to_mfn(virt_to_phys((void *)page) >>
+ PAGE_SHIFT);
+
+ /* Next allocate a local port which xenstored can bind to */
+ op.cmd = EVTCHNOP_alloc_unbound;
+ op.u.alloc_unbound.dom = DOMID_SELF;
+ op.u.alloc_unbound.remote_dom = 0;
+
+ BUG_ON(HYPERVISOR_event_channel_op(&op));
+ xen_start_info->store_evtchn = op.u.alloc_unbound.port;
+
+ /* And finally publish the above info in /proc/xen */
+ if((xsd_mfn_intf = create_xen_proc_entry("xsd_mfn", 0400)))
+ xsd_mfn_intf->read_proc = xsd_mfn_read;
+ if((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
+ xsd_port_intf->read_proc = xsd_port_read;
+ }
+
+ /* Initialize the interface to xenstore. */
+ err = xs_init();
+ if (err) {
+ printk("XENBUS: Error initializing xenstore comms: %i\n", err);
+ return err;
+ }
+
+ if (!dom0) {
+ xenstored_ready = 1;
+ xenbus_probe(NULL);
+ }
+
return 0;
}
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Mon Oct 24
15:08:13 2005
@@ -92,7 +92,7 @@
* carrying out work.
*/
static pid_t xenwatch_pid;
-static DECLARE_MUTEX(xenwatch_mutex);
+/* static */ DECLARE_MUTEX(xenwatch_mutex);
static DECLARE_WAIT_QUEUE_HEAD(watch_events_waitq);
static int get_error(const char *errorstring)
@@ -516,17 +516,38 @@
}
EXPORT_SYMBOL(xenbus_printf);
+/**
+ * Return the path to the error node for the given device, or NULL on failure.
+ * If the value returned is non-NULL, then it is the caller's to kfree.
+ */
+static char *error_path(struct xenbus_device *dev)
+{
+ char *path_buffer = kmalloc(strlen("error/") + strlen(dev->nodename) +
+ 1, GFP_KERNEL);
+ if (path_buffer == NULL) {
+ return NULL;
+ }
+
+ strcpy(path_buffer, "error/");
+ strcpy(path_buffer + strlen("error/"), dev->nodename);
+
+ return path_buffer;
+}
+
/* Report a (negative) errno into the store, with explanation. */
void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...)
{
va_list ap;
int ret;
unsigned int len;
- char *printf_buffer;
+ char *printf_buffer = NULL, *path_buffer = NULL;
printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL);
- if (printf_buffer == NULL)
+ if (printf_buffer == NULL) {
+ printk("xenbus: failed to write error node for %s (%d): %d\n",
+ dev->nodename, err, errno);
goto fail;
+ }
len = sprintf(printf_buffer, "%i ", -err);
va_start(ap, fmt);
@@ -535,15 +556,26 @@
BUG_ON(len + ret > PRINTF_BUFFER_SIZE-1);
dev->has_error = 1;
- if (xenbus_write(NULL, dev->nodename, "error", printf_buffer) != 0)
+
+ path_buffer = error_path(dev);
+
+ if (path_buffer == NULL) {
+ printk("xenbus: failed to write error node for %s (%s): %d\n",
+ dev->nodename, printf_buffer, errno);
goto fail;
-
- kfree(printf_buffer);
- return;
-
- fail:
- printk("xenbus: failed to write error node for %s (%s)\n",
- dev->nodename, printf_buffer);
+ }
+
+ if (xenbus_write(NULL, path_buffer, "error", printf_buffer) != 0) {
+ printk("xenbus: failed to write error node for %s (%s)\n",
+ dev->nodename, printf_buffer);
+ goto fail;
+ }
+
+fail:
+ if (printf_buffer)
+ kfree(printf_buffer);
+ if (path_buffer)
+ kfree(path_buffer);
}
EXPORT_SYMBOL(xenbus_dev_error);
@@ -551,11 +583,21 @@
void xenbus_dev_ok(struct xenbus_device *dev)
{
if (dev->has_error) {
- if (xenbus_rm(NULL, dev->nodename, "error") != 0)
+ char *path_buffer = error_path(dev);
+
+ if (path_buffer == NULL) {
+ printk("xenbus: failed to clear error node for %s: "
+ "%d\n", dev->nodename, errno);
+ return;
+ }
+
+ if (xenbus_rm(NULL, path_buffer, "error") != 0)
printk("xenbus: failed to clear error node for %s\n",
dev->nodename);
else
dev->has_error = 0;
+
+ kfree(path_buffer);
}
}
EXPORT_SYMBOL(xenbus_dev_ok);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypervisor.h Fri Oct
21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypervisor.h Mon Oct
24 15:08:13 2005
@@ -49,6 +49,8 @@
# define pud_t pgd_t
# endif
#endif
+
+extern shared_info_t *HYPERVISOR_shared_info;
/* arch/xen/i386/kernel/setup.c */
extern start_info_t *xen_start_info;
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h Mon Oct 24
15:08:13 2005
@@ -455,6 +455,11 @@
unsigned long size,
pgprot_t prot,
domid_t domid);
+int direct_kernel_remap_pfn_range(unsigned long address,
+ unsigned long mfn,
+ unsigned long size,
+ pgprot_t prot,
+ domid_t domid);
int create_lookup_pte_addr(struct mm_struct *mm,
unsigned long address,
unsigned long *ptep);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-i386/setup.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/setup.h Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/setup.h Mon Oct 24
15:08:13 2005
@@ -8,7 +8,7 @@
#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
-#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
+#define PFN_PHYS(x) ((unsigned long long)(x) << PAGE_SHIFT)
/*
* Reserved space for vmalloc and iomap - defined in asm/page.h
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h Mon Oct 24
15:08:13 2005
@@ -497,22 +497,11 @@
* includes these barriers, for example.
*/
-/*
- * Don't use smp_processor_id() in preemptible code: debug builds will barf.
- * It's okay in these cases as we only read the upcall mask in preemptible
- * regions, which is always safe.
- */
-#ifdef CONFIG_SMP
-#define __this_cpu() __smp_processor_id()
-#else
-#define __this_cpu() 0
-#endif
-
#define __cli()
\
do { \
vcpu_info_t *_vcpu; \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
_vcpu->evtchn_upcall_mask = 1; \
preempt_enable_no_resched(); \
barrier(); \
@@ -523,7 +512,7 @@
vcpu_info_t *_vcpu; \
barrier(); \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
_vcpu->evtchn_upcall_mask = 0; \
barrier(); /* unmask then check (avoid races) */ \
if ( unlikely(_vcpu->evtchn_upcall_pending) ) \
@@ -534,8 +523,10 @@
#define __save_flags(x)
\
do { \
vcpu_info_t *_vcpu; \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ preempt_disable(); \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
(x) = _vcpu->evtchn_upcall_mask; \
+ preempt_enable(); \
} while (0)
#define __restore_flags(x) \
@@ -543,7 +534,7 @@
vcpu_info_t *_vcpu; \
barrier(); \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \
barrier(); /* unmask then check (avoid races) */ \
if ( unlikely(_vcpu->evtchn_upcall_pending) ) \
@@ -559,7 +550,7 @@
do { \
vcpu_info_t *_vcpu; \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
(x) = _vcpu->evtchn_upcall_mask; \
_vcpu->evtchn_upcall_mask = 1; \
preempt_enable_no_resched(); \
@@ -572,8 +563,15 @@
#define local_irq_disable() __cli()
#define local_irq_enable() __sti()
+/* Cannot use preempt_enable() here as we would recurse in preempt_sched(). */
#define irqs_disabled()
\
- HYPERVISOR_shared_info->vcpu_data[__this_cpu()].evtchn_upcall_mask
+({ int ___x; \
+ vcpu_info_t *_vcpu; \
+ preempt_disable(); \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+ ___x = (_vcpu->evtchn_upcall_mask != 0); \
+ preempt_enable_no_resched(); \
+ ___x; })
/*
* disable hlt during certain critical i/o operations
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h Fri Oct
21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h Mon Oct
24 15:08:13 2005
@@ -39,6 +39,7 @@
#include <asm/ptrace.h>
#include <asm/page.h>
+extern shared_info_t *HYPERVISOR_shared_info;
extern start_info_t *xen_start_info;
void force_evtchn_callback(void);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h Mon Oct 24
15:08:13 2005
@@ -533,6 +533,12 @@
pgprot_t prot,
domid_t domid);
+int direct_kernel_remap_pfn_range(unsigned long address,
+ unsigned long mfn,
+ unsigned long size,
+ pgprot_t prot,
+ domid_t domid);
+
int create_lookup_pte_addr(struct mm_struct *mm,
unsigned long address,
unsigned long *ptep);
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/smp.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/smp.h Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/smp.h Mon Oct 24
15:08:13 2005
@@ -34,7 +34,6 @@
extern cpumask_t cpu_present_mask;
extern cpumask_t cpu_possible_map;
extern cpumask_t cpu_online_map;
-extern cpumask_t cpu_callout_map;
/*
* Private routines/data
@@ -52,8 +51,8 @@
void smp_stop_cpu(void);
extern cpumask_t cpu_sibling_map[NR_CPUS];
extern cpumask_t cpu_core_map[NR_CPUS];
-extern u8 phys_proc_id[NR_CPUS];
-extern u8 cpu_core_id[NR_CPUS];
+extern int phys_proc_id[NR_CPUS];
+extern int cpu_core_id[NR_CPUS];
#define SMP_TRAMPOLINE_BASE 0x6000
@@ -65,7 +64,7 @@
static inline int num_booting_cpus(void)
{
- return cpus_weight(cpu_callout_map);
+ return cpus_weight(cpu_possible_map);
}
#define __smp_processor_id() read_pda(cpunumber)
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h Fri Oct 21
19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h Mon Oct 24
15:08:13 2005
@@ -321,22 +321,11 @@
* includes these barriers, for example.
*/
-/*
- * Don't use smp_processor_id() in preemptible code: debug builds will barf.
- * It's okay in these cases as we only read the upcall mask in preemptible
- * regions, which is always safe.
- */
-#ifdef CONFIG_SMP
-#define __this_cpu() __smp_processor_id()
-#else
-#define __this_cpu() 0
-#endif
-
#define __cli()
\
do { \
vcpu_info_t *_vcpu; \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
_vcpu->evtchn_upcall_mask = 1; \
preempt_enable_no_resched(); \
barrier(); \
@@ -347,7 +336,7 @@
vcpu_info_t *_vcpu; \
barrier(); \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
_vcpu->evtchn_upcall_mask = 0; \
barrier(); /* unmask then check (avoid races) */ \
if ( unlikely(_vcpu->evtchn_upcall_pending) ) \
@@ -358,8 +347,10 @@
#define __save_flags(x)
\
do { \
vcpu_info_t *_vcpu; \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ preempt_disable(); \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
(x) = _vcpu->evtchn_upcall_mask; \
+ preempt_enable(); \
} while (0)
#define __restore_flags(x) \
@@ -367,7 +358,7 @@
vcpu_info_t *_vcpu; \
barrier(); \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \
barrier(); /* unmask then check (avoid races) */ \
if ( unlikely(_vcpu->evtchn_upcall_pending) ) \
@@ -383,7 +374,7 @@
do { \
vcpu_info_t *_vcpu; \
preempt_disable(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_data[__this_cpu()]; \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
(x) = _vcpu->evtchn_upcall_mask; \
_vcpu->evtchn_upcall_mask = 1; \
preempt_enable_no_resched(); \
@@ -398,8 +389,15 @@
#define local_irq_disable() __cli()
#define local_irq_enable() __sti()
+/* Cannot use preempt_enable() here as we would recurse in preempt_sched(). */
#define irqs_disabled()
\
- HYPERVISOR_shared_info->vcpu_data[__this_cpu()].evtchn_upcall_mask
+({ int ___x; \
+ vcpu_info_t *_vcpu; \
+ preempt_disable(); \
+ _vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
+ ___x = (_vcpu->evtchn_upcall_mask != 0); \
+ preempt_enable_no_resched(); \
+ ___x; })
/*
* disable hlt during certain critical i/o operations
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h Fri Oct 21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h Mon Oct 24 15:08:13 2005
@@ -44,12 +44,12 @@
*/
/* Dynamically bind a VIRQ source to Linux IRQ space. */
-extern int bind_virq_to_irq(int virq);
-extern void unbind_virq_from_irq(int virq);
+extern int bind_virq_to_irq(int virq, int cpu);
+extern void unbind_virq_from_irq(int virq, int cpu);
/* Dynamically bind an IPI source to Linux IRQ space. */
-extern int bind_ipi_to_irq(int ipi);
-extern void unbind_ipi_from_irq(int ipi);
+extern int bind_ipi_to_irq(int ipi, int cpu);
+extern void unbind_ipi_from_irq(int ipi, int cpu);
/*
* Dynamically bind an event-channel port to an IRQ-like callback handler.
@@ -99,8 +99,9 @@
* like a real IO-APIC we 'lose the interrupt edge' if the channel is
* masked.
*/
- if (synch_test_bit (port, &s->evtchn_pending[0]) &&
- !synch_test_and_set_bit(port>>5, &vcpu_info->evtchn_pending_sel)) {
+ if (synch_test_bit(port, &s->evtchn_pending[0]) &&
+ !synch_test_and_set_bit(port / BITS_PER_LONG,
+ &vcpu_info->evtchn_pending_sel)) {
vcpu_info->evtchn_upcall_pending = 1;
if (!vcpu_info->evtchn_upcall_mask)
force_evtchn_callback();
diff -r ff7c5a791ed5 -r fdea4a967bc7
linux-2.6-xen-sparse/include/asm-xen/linux-public/privcmd.h
--- a/linux-2.6-xen-sparse/include/asm-xen/linux-public/privcmd.h Fri Oct
21 19:58:39 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/linux-public/privcmd.h Mon Oct
24 15:08:13 2005
@@ -76,8 +76,6 @@
_IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
#define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \
_IOC(_IOC_READ, 'P', 4, sizeof(unsigned long))
-#define IOCTL_PRIVCMD_INITDOMAIN_STORE \
- _IOC(_IOC_READ, 'P', 5, 0)
#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
diff -r ff7c5a791ed5 -r fdea4a967bc7 patches/linux-2.6.12/net-csum.patch
--- a/patches/linux-2.6.12/net-csum.patch Fri Oct 21 19:58:39 2005
+++ b/patches/linux-2.6.12/net-csum.patch Mon Oct 24 15:08:13 2005
@@ -9,3 +9,48 @@
&& csum_tcpudp_magic(iph->saddr, iph->daddr, udplen, IPPROTO_UDP,
skb->ip_summed == CHECKSUM_HW ? skb->csum
: skb_checksum(skb, iph->ihl*4, udplen, 0))) {
+
+--- ../xen-unstable.hg/linux-2.6.12-xen0/net/ipv4/netfilter/ip_nat_proto_udp.c
2005-06-17 14:48:29.000000000 -0500
++++ linux-2.6-xen-sparse/net/ipv4/netfilter/ip_nat_proto_udp.c 2005-10-14
15:17:53.000000000 -0500
+@@ -112,11 +112,19 @@ udp_manip_pkt(struct sk_buff **pskb,
+ newport = tuple->dst.u.udp.port;
+ portptr = &hdr->dest;
+ }
+- if (hdr->check) /* 0 is a special case meaning no checksum */
+- hdr->check = ip_nat_cheat_check(~oldip, newip,
++
++ if (hdr->check) { /* 0 is a special case meaning no checksum */
++ if ((*pskb)->proto_csum_blank) {
++ hdr->check = ip_nat_cheat_check(oldip, ~newip,
++ ip_nat_cheat_check(*portptr ^ 0xFFFF,
++ newport, hdr->check));
++ } else {
++ hdr->check = ip_nat_cheat_check(~oldip, newip,
+ ip_nat_cheat_check(*portptr ^ 0xFFFF,
+ newport,
+ hdr->check));
++ }
++ }
+ *portptr = newport;
+ return 1;
+ }
+--- ../xen-unstable.hg/linux-2.6.12-xen0/net/ipv4/netfilter/ip_nat_proto_tcp.c
2005-06-17 14:48:29.000000000 -0500
++++ linux-2.6-xen-sparse/net/ipv4/netfilter/ip_nat_proto_tcp.c 2005-10-14
16:41:20.000000000 -0500
+@@ -127,10 +127,16 @@ tcp_manip_pkt(struct sk_buff **pskb,
+ if (hdrsize < sizeof(*hdr))
+ return 1;
+
+- hdr->check = ip_nat_cheat_check(~oldip, newip,
++ if ((*pskb)->proto_csum_blank) {
++ hdr->check = ip_nat_cheat_check(oldip, ~newip,
++ ip_nat_cheat_check(oldport ^ 0xFFFF,
++ newport, hdr->check));
++ } else {
++ hdr->check = ip_nat_cheat_check(~oldip, newip,
+ ip_nat_cheat_check(oldport ^ 0xFFFF,
+ newport,
+ hdr->check));
++ }
+ return 1;
+ }
+
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/block-async.c
--- a/tools/blktap/parallax/block-async.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/block-async.c Mon Oct 24 15:08:13 2005
@@ -31,11 +31,11 @@
*/
struct read_args {
- u64 addr;
+ uint64_t addr;
};
struct write_args {
- u64 addr;
+ uint64_t addr;
char *block;
};
@@ -94,7 +94,7 @@
}
-void block_read(u64 addr, io_cb_t cb, void *param)
+void block_read(uint64_t addr, io_cb_t cb, void *param)
{
struct pending_io_req *req;
@@ -113,7 +113,7 @@
}
-void block_write(u64 addr, char *block, io_cb_t cb, void *param)
+void block_write(uint64_t addr, char *block, io_cb_t cb, void *param)
{
struct pending_io_req *req;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/block-async.h
--- a/tools/blktap/parallax/block-async.h Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/block-async.h Mon Oct 24 15:08:13 2005
@@ -14,7 +14,7 @@
{
enum {IO_ADDR_T, IO_BLOCK_T, IO_INT_T} type;
union {
- u64 a;
+ uint64_t a;
char *b;
int i;
} u;
@@ -38,8 +38,8 @@
};
void radix_lock_init(struct radix_lock *r);
-void block_read(u64 addr, io_cb_t cb, void *param);
-void block_write(u64 addr, char *block, io_cb_t cb, void *param);
+void block_read(uint64_t addr, io_cb_t cb, void *param);
+void block_write(uint64_t addr, char *block, io_cb_t cb, void *param);
void block_alloc(char *block, io_cb_t cb, void *param);
void block_rlock(struct radix_lock *r, int row, io_cb_t cb, void *param);
void block_wlock(struct radix_lock *r, int row, io_cb_t cb, void *param);
@@ -47,7 +47,7 @@
void block_wunlock(struct radix_lock *r, int row, io_cb_t cb, void *param);
void init_block_async(void);
-static inline u64 IO_ADDR(struct io_ret r)
+static inline uint64_t IO_ADDR(struct io_ret r)
{
assert(r.type == IO_ADDR_T);
return r.u.a;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/blockstore.c
--- a/tools/blktap/parallax/blockstore.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/blockstore.c Mon Oct 24 15:08:13 2005
@@ -132,9 +132,9 @@
#define ENTER_LUID_CR pthread_mutex_lock(&ptmutex_luid)
#define LEAVE_LUID_CR pthread_mutex_unlock(&ptmutex_luid)
-static u64 luid_cnt = 0x1000ULL;
-u64 new_luid(void) {
- u64 luid;
+static uint64_t luid_cnt = 0x1000ULL;
+uint64_t new_luid(void) {
+ uint64_t luid;
ENTER_LUID_CR;
luid = luid_cnt++;
LEAVE_LUID_CR;
@@ -539,7 +539,7 @@
* Reading *
*****************************************************************************/
-void *readblock_indiv(int server, u64 id) {
+void *readblock_indiv(int server, uint64_t id) {
void *block;
bsq_t *qe;
int len, rc;
@@ -616,9 +616,9 @@
*
* @return: pointer to block, NULL on error
*/
-void *readblock(u64 id) {
+void *readblock(uint64_t id) {
int map = (int)BSID_MAP(id);
- u64 xid;
+ uint64_t xid;
static int i = CLUSTER_MAX_REPLICAS - 1;
void *block = NULL;
@@ -670,7 +670,7 @@
* Writing *
*****************************************************************************/
-bsq_t *writeblock_indiv(int server, u64 id, void *block) {
+bsq_t *writeblock_indiv(int server, uint64_t id, void *block) {
bsq_t *qe;
int len;
@@ -709,7 +709,7 @@
*
* @return: zero on success, -1 on failure
*/
-int writeblock(u64 id, void *block) {
+int writeblock(uint64_t id, void *block) {
int map = (int)BSID_MAP(id);
int rep0 = bsclusters[map].servers[0];
@@ -805,11 +805,11 @@
*
* @return: new id of block on disk
*/
-u64 allocblock(void *block) {
+uint64_t allocblock(void *block) {
return allocblock_hint(block, 0);
}
-bsq_t *allocblock_hint_indiv(int server, void *block, u64 hint) {
+bsq_t *allocblock_hint_indiv(int server, void *block, uint64_t hint) {
bsq_t *qe;
int len;
@@ -846,14 +846,14 @@
*
* @return: new id of block on disk
*/
-u64 allocblock_hint(void *block, u64 hint) {
+uint64_t allocblock_hint(void *block, uint64_t hint) {
int map = (int)hint;
int rep0 = bsclusters[map].servers[0];
int rep1 = bsclusters[map].servers[1];
int rep2 = bsclusters[map].servers[2];
bsq_t *reqs[3];
int rc;
- u64 id0, id1, id2;
+ uint64_t id0, id1, id2;
reqs[0] = reqs[1] = reqs[2] = NULL;
@@ -938,7 +938,7 @@
* @return: pointer to block, NULL on error
*/
-void *readblock(u64 id) {
+void *readblock(uint64_t id) {
void *block;
int block_fp;
@@ -980,7 +980,7 @@
*
* @return: zero on success, -1 on failure
*/
-int writeblock(u64 id, void *block) {
+int writeblock(uint64_t id, void *block) {
int block_fp;
@@ -1014,8 +1014,8 @@
* @return: new id of block on disk
*/
-u64 allocblock(void *block) {
- u64 lb;
+uint64_t allocblock(void *block) {
+ uint64_t lb;
off64_t pos;
int block_fp;
@@ -1057,7 +1057,7 @@
*
* @return: new id of block on disk
*/
-u64 allocblock_hint(void *block, u64 hint) {
+uint64_t allocblock_hint(void *block, uint64_t hint) {
return allocblock(block);
}
@@ -1109,7 +1109,7 @@
return fb;
}
-void releaseblock(u64 id)
+void releaseblock(uint64_t id)
{
blockstore_super_t *bs_super;
freeblock_t *fl_current;
@@ -1154,7 +1154,7 @@
{
blockstore_super_t *bs_super;
freeblock_t *fb;
- u64 total = 0, next;
+ uint64_t total = 0, next;
bs_super = (blockstore_super_t *) readblock(BLOCKSTORE_SUPER);
@@ -1205,7 +1205,7 @@
{
int i;
blockstore_super_t *bs_super;
- u64 ret;
+ uint64_t ret;
int block_fp;
#ifdef BLOCKSTORE_REMOTE
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/blockstore.h
--- a/tools/blktap/parallax/blockstore.h Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/blockstore.h Mon Oct 24 15:08:13 2005
@@ -21,33 +21,33 @@
#define SECTOR_SHIFT 9
#endif
-#define FREEBLOCK_SIZE (BLOCK_SIZE / sizeof(u64)) - (3 * sizeof(u64))
+#define FREEBLOCK_SIZE (BLOCK_SIZE / sizeof(uint64_t)) - (3 *
sizeof(uint64_t))
#define FREEBLOCK_MAGIC 0x0fee0fee0fee0feeULL
typedef struct {
- u64 magic;
- u64 next;
- u64 count;
- u64 list[FREEBLOCK_SIZE];
+ uint64_t magic;
+ uint64_t next;
+ uint64_t count;
+ uint64_t list[FREEBLOCK_SIZE];
} freeblock_t;
#define BLOCKSTORE_MAGIC 0xaaaaaaa00aaaaaaaULL
#define BLOCKSTORE_SUPER 1ULL
typedef struct {
- u64 magic;
- u64 freelist_full;
- u64 freelist_current;
+ uint64_t magic;
+ uint64_t freelist_full;
+ uint64_t freelist_current;
} blockstore_super_t;
extern void *newblock();
-extern void *readblock(u64 id);
-extern u64 allocblock(void *block);
-extern u64 allocblock_hint(void *block, u64 hint);
-extern int writeblock(u64 id, void *block);
+extern void *readblock(uint64_t id);
+extern uint64_t allocblock(void *block);
+extern uint64_t allocblock_hint(void *block, uint64_t hint);
+extern int writeblock(uint64_t id, void *block);
/* Add this blockid to a freelist, to be recycled by the allocator. */
-extern void releaseblock(u64 id);
+extern void releaseblock(uint64_t id);
/* this is a memory free() operation for block-sized allocations */
extern void freeblock(void *block);
@@ -55,17 +55,17 @@
/* debug for freelist. */
void freelist_count(int print_each);
-#define ALLOCFAIL (((u64)(-1)))
+#define ALLOCFAIL (((uint64_t)(-1)))
/* Distribution
*/
#define BLOCKSTORED_PORT 9346
struct bshdr_t_struct {
- u32 operation;
- u32 flags;
- u64 id;
- u64 luid;
+ uint32_t operation;
+ uint32_t flags;
+ uint64_t id;
+ uint64_t luid;
} __attribute__ ((packed));
typedef struct bshdr_t_struct bshdr_t;
@@ -76,9 +76,9 @@
typedef struct bsmsg_t_struct bsmsg_t;
-#define MSGBUFSIZE_OP sizeof(u32)
-#define MSGBUFSIZE_FLAGS (sizeof(u32) + sizeof(u32))
-#define MSGBUFSIZE_ID (sizeof(u32) + sizeof(u32) + sizeof(u64) +
sizeof(u64))
+#define MSGBUFSIZE_OP sizeof(uint32_t)
+#define MSGBUFSIZE_FLAGS (sizeof(uint32_t) + sizeof(uint32_t))
+#define MSGBUFSIZE_ID (sizeof(uint32_t) + sizeof(uint32_t) +
sizeof(uint64_t) + sizeof(uint64_t))
#define MSGBUFSIZE_BLOCK sizeof(bsmsg_t)
#define BSOP_READBLOCK 0x01
@@ -113,9 +113,9 @@
#define BSID_REPLICA2(_id) (((_id)>>40)&0xfffffULL)
#define BSID_MAP(_id) (((_id)>>60)&0xfULL)
-#define BSID(_map, _rep0, _rep1, _rep2) ((((u64)(_map))<<60) | \
- (((u64)(_rep2))<<40) | \
- (((u64)(_rep1))<<20) | ((u64)(_rep0)))
+#define BSID(_map, _rep0, _rep1, _rep2) ((((uint64_t)(_map))<<60) | \
+ (((uint64_t)(_rep2))<<40) | \
+ (((uint64_t)(_rep1))<<20) |
((uint64_t)(_rep0)))
typedef struct bsserver_t_struct {
char *hostname;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/blockstored.c
--- a/tools/blktap/parallax/blockstored.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/blockstored.c Mon Oct 24 15:08:13 2005
@@ -21,9 +21,9 @@
//#define BSDEBUG
-int readblock_into(u64 id, void *block);
-
-int open_socket(u16 port) {
+int readblock_into(uint64_t id, void *block);
+
+int open_socket(uint16_t port) {
struct sockaddr_in sn;
int sock;
@@ -75,7 +75,7 @@
int rc, len;
struct sockaddr_in from;
size_t slen = sizeof(from);
- u64 bid;
+ uint64_t bid;
len = recvfrom(bssock, (void *)&msgbuf, sizeof(msgbuf), 0,
(struct sockaddr *)&from, &slen);
@@ -155,7 +155,7 @@
* @return: 0 if OK, other on error
*/
-int readblock_into(u64 id, void *block) {
+int readblock_into(uint64_t id, void *block) {
if (lseek64(block_fp, ((off64_t) id - 1LL) * BLOCK_SIZE, SEEK_SET) < 0) {
printf ("%Ld\n", (id - 1) * BLOCK_SIZE);
perror("readblock lseek");
@@ -175,7 +175,7 @@
*
* @return: zero on success, -1 on failure
*/
-int writeblock(u64 id, void *block) {
+int writeblock(uint64_t id, void *block) {
if (lseek64(block_fp, ((off64_t) id - 1LL) * BLOCK_SIZE, SEEK_SET) < 0) {
perror("writeblock lseek");
return -1;
@@ -193,10 +193,10 @@
*
* @return: new id of block on disk
*/
-static u64 lastblock = 0;
-
-u64 allocblock(void *block) {
- u64 lb;
+static uint64_t lastblock = 0;
+
+uint64_t allocblock(void *block) {
+ uint64_t lb;
off64_t pos;
retry:
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/bstest.c
--- a/tools/blktap/parallax/bstest.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/bstest.c Mon Oct 24 15:08:13 2005
@@ -22,7 +22,7 @@
#include <errno.h>
#include "blockstore.h"
-int direct(char *host, u32 op, u64 id, int len) {
+int direct(char *host, uint32_t op, uint64_t id, int len) {
struct sockaddr_in sn, peer;
int sock;
bsmsg_t msgbuf;
@@ -99,8 +99,8 @@
int main (int argc, char **argv) {
- u32 op = 0;
- u64 id = 0;
+ uint32_t op = 0;
+ uint64_t id = 0;
int len = 0, rc;
void *block;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/parallax.c
--- a/tools/blktap/parallax/parallax.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/parallax.c Mon Oct 24 15:08:13 2005
@@ -330,8 +330,8 @@
struct cb_param {
pending_t *pent;
int segment;
- u64 sector;
- u64 vblock; /* for debug printing -- can be removed. */
+ uint64_t sector;
+ uint64_t vblock; /* for debug printing -- can be removed. */
};
static void read_cb(struct io_ret r, void *in_param)
@@ -393,9 +393,9 @@
int parallax_read(blkif_request_t *req, blkif_t *blkif)
{
blkif_response_t *rsp;
- u64 vblock, gblock;
+ uint64_t vblock, gblock;
vdi_t *vdi;
- u64 sector;
+ uint64_t sector;
int i;
char *dpage, *spage;
pending_t *pent;
@@ -475,9 +475,9 @@
int parallax_write(blkif_request_t *req, blkif_t *blkif)
{
blkif_response_t *rsp;
- u64 sector;
+ uint64_t sector;
int i, writable = 0;
- u64 vblock, gblock;
+ uint64_t vblock, gblock;
char *spage;
unsigned long size, offset, start;
vdi_t *vdi;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/radix.c
--- a/tools/blktap/parallax/radix.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/radix.c Mon Oct 24 15:08:13 2005
@@ -33,7 +33,7 @@
typedef struct rcache_st {
radix_tree_node *node;
- u64 id;
+ uint64_t id;
struct rcache_st *hash_next;
struct rcache_st *cache_next;
struct rcache_st *cache_prev;
@@ -55,7 +55,7 @@
}
-void rcache_write(u64 id, radix_tree_node *node)
+void rcache_write(uint64_t id, radix_tree_node *node)
{
rcache_t *r, *tmp, **curs;
@@ -135,7 +135,7 @@
pthread_mutex_unlock(&rcache_mutex);
}
-radix_tree_node *rcache_read(u64 id)
+radix_tree_node *rcache_read(uint64_t id)
{
rcache_t *r, *tmp;
radix_tree_node *node = NULL;
@@ -181,7 +181,7 @@
}
-void *rc_readblock(u64 id)
+void *rc_readblock(uint64_t id)
{
void *ret;
@@ -197,9 +197,9 @@
return(ret);
}
-u64 rc_allocblock(void *block)
-{
- u64 ret;
+uint64_t rc_allocblock(void *block)
+{
+ uint64_t ret;
ret = allocblock(block);
@@ -209,7 +209,7 @@
return(ret);
}
-int rc_writeblock(u64 id, void *block)
+int rc_writeblock(uint64_t id, void *block)
{
int ret;
@@ -233,9 +233,9 @@
* whether or not the block is writable, including the return
* values of update and snapshot
*/
-u64 lookup(int height, u64 root, u64 key);
-u64 update(int height, u64 root, u64 key, u64 val);
-u64 snapshot(u64 root);
+uint64_t lookup(int height, uint64_t root, uint64_t key);
+uint64_t update(int height, uint64_t root, uint64_t key, uint64_t val);
+uint64_t snapshot(uint64_t root);
/**
* cloneblock: clone an existing block in memory
@@ -264,9 +264,9 @@
* @return: value on success, zero on error
*/
-u64 lookup(int height, u64 root, u64 key) {
+uint64_t lookup(int height, uint64_t root, uint64_t key) {
radix_tree_node node;
- u64 mask = ONE;
+ uint64_t mask = ONE;
assert(key >> height == 0);
@@ -275,7 +275,7 @@
/* now carve off equal sized chunks at each step */
for (;;) {
- u64 oldroot;
+ uint64_t oldroot;
#ifdef DEBUG
printf("lookup: height=%3d root=%3Ld offset=%3d%s\n", height, root,
@@ -314,9 +314,9 @@
* @returns: (possibly new) root id on success (with LSB=1), 0 on failure
*/
-u64 update(int height, u64 root, u64 key, u64 val) {
+uint64_t update(int height, uint64_t root, uint64_t key, uint64_t val) {
int offset;
- u64 child;
+ uint64_t child;
radix_tree_node node;
/* base case--return val */
@@ -390,7 +390,7 @@
*
* @return: new root node, 0 on error
*/
-u64 snapshot(u64 root) {
+uint64_t snapshot(uint64_t root) {
radix_tree_node node, newnode;
if ((node = rc_readblock(getid(root))) == NULL)
@@ -418,7 +418,7 @@
* child are okay...)
*/
-int collapse(int height, u64 proot, u64 croot)
+int collapse(int height, uint64_t proot, uint64_t croot)
{
int i, numlinks, ret, total = 0;
radix_tree_node pnode, cnode;
@@ -480,7 +480,7 @@
}
-void print_root(u64 root, int height, FILE *dot_f)
+void print_root(uint64_t root, int height, FILE *dot_f)
{
FILE *f;
int i;
@@ -558,9 +558,9 @@
#ifdef RADIX_STANDALONE
int main(int argc, char **argv) {
- u64 key = ZERO, val = ZERO;
- u64 root = writable(2ULL);
- u64 p = ZERO, c = ZERO;
+ uint64_t key = ZERO, val = ZERO;
+ uint64_t root = writable(2ULL);
+ uint64_t p = ZERO, c = ZERO;
int v;
char buff[4096];
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/radix.h
--- a/tools/blktap/parallax/radix.h Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/radix.h Mon Oct 24 15:08:13 2005
@@ -24,7 +24,7 @@
#define RADIX_TREE_MAP_MASK 0x1ff
#define RADIX_TREE_MAP_ENTRIES 512
-typedef u64 *radix_tree_node;
+typedef uint64_t *radix_tree_node;
/*
@@ -33,11 +33,11 @@
* whether or not the block is writable, including the return
* values of update and snapshot
*/
-u64 lookup(int height, u64 root, u64 key);
-u64 update(int height, u64 root, u64 key, u64 val);
-u64 snapshot(u64 root);
-int collapse(int height, u64 proot, u64 croot);
-int isprivate(int height, u64 root, u64 key);
+uint64_t lookup(int height, uint64_t root, uint64_t key);
+uint64_t update(int height, uint64_t root, uint64_t key, uint64_t val);
+uint64_t snapshot(uint64_t root);
+int collapse(int height, uint64_t proot, uint64_t croot);
+int isprivate(int height, uint64_t root, uint64_t key);
void __rcache_init(void);
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/requests-async.c
--- a/tools/blktap/parallax/requests-async.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/requests-async.c Mon Oct 24 15:08:13 2005
@@ -27,14 +27,14 @@
#endif
struct block_info {
- u32 crc;
- u32 unused;
+ uint32_t crc;
+ uint32_t unused;
};
struct io_req {
enum { IO_OP_READ, IO_OP_WRITE } op;
- u64 root;
- u64 vaddr;
+ uint64_t root;
+ uint64_t vaddr;
int state;
io_cb_t cb;
void *param;
@@ -44,7 +44,7 @@
struct io_ret retval;/* holds the return while we unlock. */
char *block; /* the block to write */
radix_tree_node radix[3];
- u64 radix_addr[3];
+ uint64_t radix_addr[3];
struct block_info bi;
};
@@ -129,7 +129,7 @@
static void read_cb(struct io_ret ret, void *param);
static void write_cb(struct io_ret ret, void *param);
-int vdi_read(vdi_t *vdi, u64 vaddr, io_cb_t cb, void *param)
+int vdi_read(vdi_t *vdi, uint64_t vaddr, io_cb_t cb, void *param)
{
struct io_req *req;
@@ -156,7 +156,7 @@
}
-int vdi_write(vdi_t *vdi, u64 vaddr, char *block,
+int vdi_write(vdi_t *vdi, uint64_t vaddr, char *block,
io_cb_t cb, void *param)
{
struct io_req *req;
@@ -177,8 +177,8 @@
req->block = block;
/* Todo: add a pseodoheader to the block to include some location */
/* information in the CRC as well. */
- req->bi.crc = (u32) crc32(0L, Z_NULL, 0);
- req->bi.crc = (u32) crc32(req->bi.crc, block, BLOCK_SIZE);
+ req->bi.crc = (uint32_t) crc32(0L, Z_NULL, 0);
+ req->bi.crc = (uint32_t) crc32(req->bi.crc, block, BLOCK_SIZE);
req->bi.unused = 0xdeadbeef;
req->cb = cb;
@@ -196,7 +196,7 @@
{
struct io_req *req = (struct io_req *)param;
radix_tree_node node;
- u64 idx;
+ uint64_t idx;
char *block;
void *req_param;
@@ -268,15 +268,15 @@
}
case READ_DATA:
{
- u32 crc;
+ uint32_t crc;
DPRINTF("READ_DATA\n");
block = IO_BLOCK(ret);
if (block == NULL) goto fail;
/* crc check */
- crc = (u32) crc32(0L, Z_NULL, 0);
- crc = (u32) crc32(crc, block, BLOCK_SIZE);
+ crc = (uint32_t) crc32(0L, Z_NULL, 0);
+ crc = (uint32_t) crc32(crc, block, BLOCK_SIZE);
if (crc != req->bi.crc) {
/* TODO: add a retry loop here. */
/* Do this after the cache is added -- make sure to */
@@ -359,7 +359,7 @@
{
struct io_req *req = (struct io_req *)param;
radix_tree_node node;
- u64 a, addr;
+ uint64_t a, addr;
void *req_param;
struct block_info *bi;
@@ -721,7 +721,7 @@
}
}
-char *vdi_read_s(vdi_t *vdi, u64 vaddr)
+char *vdi_read_s(vdi_t *vdi, uint64_t vaddr)
{
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
char *block = NULL;
@@ -742,7 +742,7 @@
}
-int vdi_write_s(vdi_t *vdi, u64 vaddr, char *block)
+int vdi_write_s(vdi_t *vdi, uint64_t vaddr, char *block)
{
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
int ret, result;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/requests-async.h
--- a/tools/blktap/parallax/requests-async.h Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/requests-async.h Mon Oct 24 15:08:13 2005
@@ -10,18 +10,18 @@
#define getid(x) (((x)>>1)&0x7fffffffffffffffLLU)
#define iswritable(x) (((x) & 1LLU) != 0)
#define writable(x) (((x) << 1) | 1LLU)
-#define readonly(x) ((u64)((x) << 1))
+#define readonly(x) ((uint64_t)((x) << 1))
*/
#define VADDR_MASK 0x0000000003ffffffLLU /* 26-bits = 256Gig */
#define VALID_VADDR(x) (((x) & VADDR_MASK) == (x))
-int vdi_read (vdi_t *vdi, u64 vaddr, io_cb_t cb, void *param);
-int vdi_write(vdi_t *vdi, u64 vaddr, char *block, io_cb_t cb, void *param);
+int vdi_read (vdi_t *vdi, uint64_t vaddr, io_cb_t cb, void *param);
+int vdi_write(vdi_t *vdi, uint64_t vaddr, char *block, io_cb_t cb, void
*param);
/* synchronous versions: */
-char *vdi_read_s (vdi_t *vdi, u64 vaddr);
-int vdi_write_s(vdi_t *vdi, u64 vaddr, char *block);
+char *vdi_read_s (vdi_t *vdi, uint64_t vaddr);
+int vdi_write_s(vdi_t *vdi, uint64_t vaddr, char *block);
#define ERR_BAD_VADDR -1
#define ERR_NOMEM -2
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/snaplog.c
--- a/tools/blktap/parallax/snaplog.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/snaplog.c Mon Oct 24 15:08:13 2005
@@ -24,7 +24,7 @@
-snap_block_t *snap_get_block(u64 block)
+snap_block_t *snap_get_block(uint64_t block)
{
snap_block_t *blk = (snap_block_t *)readblock(block);
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/snaplog.h
--- a/tools/blktap/parallax/snaplog.h Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/snaplog.h Mon Oct 24 15:08:13 2005
@@ -13,12 +13,12 @@
#define __SNAPLOG_H__
typedef struct snap_id {
- u64 block;
+ uint64_t block;
unsigned int index;
} snap_id_t;
typedef struct snap_rec {
- u64 radix_root;
+ uint64_t radix_root;
struct timeval timestamp;
/* flags: */
unsigned deleted:1;
@@ -38,7 +38,7 @@
static const snap_id_t null_snap_id = { 0, 0 };
typedef struct snap_block_hdr {
- u64 magic;
+ uint64_t magic;
snap_id_t parent_block; /* parent block within this chain */
snap_id_t fork_block; /* where this log was forked */
unsigned log_entries; /* total entries since forking */
@@ -56,6 +56,6 @@
} snap_block_t;
-snap_block_t *snap_get_block(u64 block);
+snap_block_t *snap_get_block(uint64_t block);
#endif /* __SNAPLOG_H__ */
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi.c
--- a/tools/blktap/parallax/vdi.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi.c Mon Oct 24 15:08:13 2005
@@ -132,9 +132,9 @@
/* vdi_get and vdi_put currently act more like alloc/free -- they don't
* do refcount-based allocation.
*/
-vdi_t *vdi_get(u64 vdi_id)
-{
- u64 vdi_blk;
+vdi_t *vdi_get(uint64_t vdi_id)
+{
+ uint64_t vdi_blk;
vdi_t *vdi;
vdi_blk = lookup(VDI_REG_HEIGHT, VDI_RADIX_ROOT, vdi_id);
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi.h
--- a/tools/blktap/parallax/vdi.h Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi.h Mon Oct 24 15:08:13 2005
@@ -21,9 +21,9 @@
typedef struct vdi {
- u64 id; /* unique vdi id -- used by the registry */
- u64 block; /* block where this vdi lives (also unique)*/
- u64 radix_root; /* radix root node for block mappings */
+ uint64_t id; /* unique vdi id -- used by the
registry */
+ uint64_t block; /* block where this vdi lives (also
unique)*/
+ uint64_t radix_root; /* radix root node for block mappings
*/
snap_id_t snap; /* next snapshot slot for this VDI */
struct vdi *next; /* used to hash-chain in blkif. */
blkif_vdev_t vdevice; /* currently mounted as... */
@@ -34,19 +34,19 @@
#define VDI_REG_MAGIC 0xff00ff0bb0ff00ffLL
typedef struct vdi_registry {
- u64 magic;
- u64 nr_vdis;
+ uint64_t magic;
+ uint64_t nr_vdis;
} vdi_registry_t;
int __init_vdi(void);
-vdi_t *vdi_get(u64 vdi_id);
+vdi_t *vdi_get(uint64_t vdi_id);
void vdi_put(vdi_t *vdi);
vdi_registry_t *get_vdi_registry(void);
vdi_t *vdi_create(snap_id_t *parent_snap, char *name);
-u64 vdi_lookup_block(vdi_t *vdi, u64 vdi_block, int *writable);
-void vdi_update_block(vdi_t *vdi, u64 vdi_block, u64 g_block);
+uint64_t vdi_lookup_block(vdi_t *vdi, uint64_t vdi_block, int *writable);
+void vdi_update_block(vdi_t *vdi, uint64_t vdi_block, uint64_t g_block);
void vdi_snapshot(vdi_t *vdi);
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi_create.c
--- a/tools/blktap/parallax/vdi_create.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi_create.c Mon Oct 24 15:08:13 2005
@@ -33,7 +33,7 @@
name[VDI_NAME_SZ] = '\0';
if ( argc > 3 ) {
- id.block = (u64) atoll(argv[2]);
+ id.block = (uint64_t) atoll(argv[2]);
id.index = (unsigned int) atol (argv[3]);
from_snap = 1;
}
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi_fill.c
--- a/tools/blktap/parallax/vdi_fill.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi_fill.c Mon Oct 24 15:08:13 2005
@@ -22,13 +22,13 @@
int main(int argc, char *argv[])
{
vdi_t *vdi;
- u64 id;
+ uint64_t id;
int fd;
struct stat st;
- u64 tot_size;
+ uint64_t tot_size;
char spage[BLOCK_SIZE];
char *dpage;
- u64 vblock = 0, count=0;
+ uint64_t vblock = 0, count=0;
__init_blockstore();
init_block_async();
@@ -39,7 +39,7 @@
exit(-1);
}
- id = (u64) atoll(argv[1]);
+ id = (uint64_t) atoll(argv[1]);
vdi = vdi_get( id );
@@ -60,7 +60,7 @@
exit(-1);
}
- tot_size = (u64) st.st_size;
+ tot_size = (uint64_t) st.st_size;
printf("Filling VDI %Ld with %Ld bytes.\n", id, tot_size);
printf("%011Ld blocks total\n", tot_size / BLOCK_SIZE);
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi_snap.c
--- a/tools/blktap/parallax/vdi_snap.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi_snap.c Mon Oct 24 15:08:13 2005
@@ -17,7 +17,7 @@
int main(int argc, char *argv[])
{
vdi_t *vdi;
- u64 id;
+ uint64_t id;
__init_blockstore();
__init_vdi();
@@ -27,7 +27,7 @@
exit(-1);
}
- id = (u64) atoll(argv[1]);
+ id = (uint64_t) atoll(argv[1]);
vdi = vdi_get(id);
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi_snap_delete.c
--- a/tools/blktap/parallax/vdi_snap_delete.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi_snap_delete.c Mon Oct 24 15:08:13 2005
@@ -34,7 +34,7 @@
exit(-1);
}
- id.block = (u64) atoll(argv[1]);
+ id.block = (uint64_t) atoll(argv[1]);
id.index = (unsigned int) atol (argv[2]);
c_id = id;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi_snap_list.c
--- a/tools/blktap/parallax/vdi_snap_list.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi_snap_list.c Mon Oct 24 15:08:13 2005
@@ -18,7 +18,7 @@
int main(int argc, char *argv[])
{
vdi_t *vdi;
- u64 id;
+ uint64_t id;
int i, max_snaps = -1;
snap_block_t *blk;
snap_id_t sid;
@@ -32,7 +32,7 @@
exit(-1);
}
- id = (u64) atoll(argv[1]);
+ id = (uint64_t) atoll(argv[1]);
if ( argc > 2 ) {
max_snaps = atoi(argv[2]);
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi_unittest.c
--- a/tools/blktap/parallax/vdi_unittest.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi_unittest.c Mon Oct 24 15:08:13 2005
@@ -39,9 +39,9 @@
zero_page = newblock();
}
-inline u64 make_vaddr(u64 L1, u64 L2, u64 L3)
+inline uint64_t make_vaddr(uint64_t L1, uint64_t L2, uint64_t L3)
{
- u64 ret = L1;
+ uint64_t ret = L1;
ret = (ret << 9) | L2;
ret = (ret << 9) | L3;
@@ -49,9 +49,9 @@
return ret;
}
-void touch_block(vdi_t *vdi, u64 L1, u64 L2, u64 L3)
+void touch_block(vdi_t *vdi, uint64_t L1, uint64_t L2, uint64_t L3)
{
- u64 vaddr;
+ uint64_t vaddr;
char *page = pages[next_page++];
char *rpage = NULL;
@@ -76,9 +76,9 @@
freeblock(rpage);
}
-void test_block(vdi_t *vdi, u64 L1, u64 L2, u64 L3, char *page)
+void test_block(vdi_t *vdi, uint64_t L1, uint64_t L2, uint64_t L3, char *page)
{
- u64 vaddr;
+ uint64_t vaddr;
char *rpage = NULL;
printf("TEST (%3Lu, %3Lu, %3Lu)\n", L1, L2, L3);
@@ -103,7 +103,7 @@
void coverage_test(vdi_t *vdi)
{
- u64 vaddr;
+ uint64_t vaddr;
int i, j, k;
/* Do a series of writes and reads to test all paths through the
@@ -155,13 +155,13 @@
int main(int argc, char *argv[])
{
vdi_t *vdi;
- u64 id;
+ uint64_t id;
int fd;
struct stat st;
- u64 tot_size;
+ uint64_t tot_size;
char spage[BLOCK_SIZE];
char *dpage;
- u64 vblock = 0, count=0;
+ uint64_t vblock = 0, count=0;
__init_blockstore();
init_block_async();
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/parallax/vdi_validate.c
--- a/tools/blktap/parallax/vdi_validate.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/parallax/vdi_validate.c Mon Oct 24 15:08:13 2005
@@ -23,13 +23,13 @@
int main(int argc, char *argv[])
{
vdi_t *vdi;
- u64 id;
+ uint64_t id;
int fd;
struct stat st;
- u64 tot_size;
+ uint64_t tot_size;
char spage[BLOCK_SIZE], *dpage;
char *vpage;
- u64 vblock = 0, count=0;
+ uint64_t vblock = 0, count=0;
__init_blockstore();
init_block_async();
@@ -40,7 +40,7 @@
exit(-1);
}
- id = (u64) atoll(argv[1]);
+ id = (uint64_t) atoll(argv[1]);
vdi = vdi_get( id );
@@ -61,7 +61,7 @@
exit(-1);
}
- tot_size = (u64) st.st_size;
+ tot_size = (uint64_t) st.st_size;
printf("Testing VDI %Ld (%Ld bytes).\n", id, tot_size);
printf(" ");
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/blktap/ublkback/ublkbacklib.c
--- a/tools/blktap/ublkback/ublkbacklib.c Fri Oct 21 19:58:39 2005
+++ b/tools/blktap/ublkback/ublkbacklib.c Mon Oct 24 15:08:13 2005
@@ -112,7 +112,7 @@
typedef struct image {
/* These need to turn into an array/rbtree for multi-disk support. */
int fd;
- u64 fsid;
+ uint64_t fsid;
blkif_vdev_t vdevice;
long int size;
long int secsize;
@@ -190,7 +190,7 @@
}
*/
if (image->size == 0)
- image->size =((u64) 16836057);
+ image->size =((uint64_t) 16836057);
image->secsize = 512;
image->info = 0;
@@ -215,7 +215,7 @@
int ublkback_request(blkif_t *blkif, blkif_request_t *req, int batch_done)
{
int fd;
- u64 sector;
+ uint64_t sector;
char *spage, *dpage;
int ret, i, idx;
blkif_response_t *rsp;
diff -r ff7c5a791ed5 -r fdea4a967bc7 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Fri Oct 21 19:58:39 2005
+++ b/tools/console/daemon/io.c Mon Oct 24 15:08:13 2005
@@ -79,44 +79,43 @@
static void buffer_append(struct domain *dom)
{
struct buffer *buffer = &dom->buffer;
- size_t size;
- XENCONS_RING_IDX oldcons;
- int notify = 0;
+ XENCONS_RING_IDX cons, prod, size;
struct xencons_interface *intf = dom->interface;
- while ((size = (intf->out_prod - intf->out_cons)) != 0) {
- notify = 1;
-
- if ((buffer->capacity - buffer->size) < size) {
- buffer->capacity += (size + 1024);
- buffer->data = realloc(buffer->data, buffer->capacity);
- if (buffer->data == NULL) {
- dolog(LOG_ERR, "Memory allocation failed");
- exit(ENOMEM);
- }
- }
-
- oldcons = intf->out_cons;
- while ((intf->out_cons - oldcons) < size) {
- buffer->data[buffer->size] = intf->out[
- MASK_XENCONS_IDX(intf->out_cons, intf->out)];
- buffer->size++;
- intf->out_cons++;
- }
-
- if (buffer->max_capacity &&
- buffer->size > buffer->max_capacity) {
- memmove(buffer->data + (buffer->size -
- buffer->max_capacity),
- buffer->data, buffer->max_capacity);
- buffer->data = realloc(buffer->data,
- buffer->max_capacity);
- buffer->capacity = buffer->max_capacity;
- }
- }
-
- if (notify)
- evtchn_notify(dom);
+ cons = intf->out_cons;
+ prod = intf->out_prod;
+ mb();
+
+ size = prod - cons;
+ if ((size == 0) || (size > sizeof(intf->out)))
+ return;
+
+ if ((buffer->capacity - buffer->size) < size) {
+ buffer->capacity += (size + 1024);
+ buffer->data = realloc(buffer->data, buffer->capacity);
+ if (buffer->data == NULL) {
+ dolog(LOG_ERR, "Memory allocation failed");
+ exit(ENOMEM);
+ }
+ }
+
+ while (cons != prod)
+ buffer->data[buffer->size++] = intf->out[
+ MASK_XENCONS_IDX(cons++, intf->out)];
+
+ mb();
+ intf->out_cons = cons;
+ evtchn_notify(dom);
+
+ if (buffer->max_capacity &&
+ buffer->size > buffer->max_capacity) {
+ memmove(buffer->data + (buffer->size -
+ buffer->max_capacity),
+ buffer->data, buffer->max_capacity);
+ buffer->data = realloc(buffer->data,
+ buffer->max_capacity);
+ buffer->capacity = buffer->max_capacity;
+ }
}
static bool buffer_empty(struct buffer *buffer)
@@ -164,6 +163,16 @@
tcsetattr(master, TCSAFLUSH, &term);
}
+ success = asprintf(&path, "%s/limit", dom->conspath) != -1;
+ if (!success)
+ goto out;
+ data = xs_read(xs, NULL, path, &len);
+ if (data) {
+ dom->buffer.max_capacity = strtoul(data, 0, 0);
+ free(data);
+ }
+ free(path);
+
success = asprintf(&path, "%s/tty", dom->conspath) != -1;
if (!success)
goto out;
@@ -171,16 +180,6 @@
free(path);
if (!success)
goto out;
-
- success = asprintf(&path, "%s/limit", dom->conspath) != -1;
- if (!success)
- goto out;
- data = xs_read(xs, NULL, path, &len);
- if (data) {
- dom->buffer.max_capacity = strtoul(data, 0, 0);
- free(data);
- }
- free(path);
}
return master;
@@ -270,6 +269,18 @@
}
dom->local_port = rc;
+ if (dom->tty_fd == -1) {
+ dom->tty_fd = domain_create_tty(dom);
+
+ if (dom->tty_fd == -1) {
+ err = errno;
+ close(dom->evtchn_fd);
+ dom->evtchn_fd = -1;
+ dom->local_port = -1;
+ goto out;
+ }
+ }
+
out:
return err;
}
@@ -302,10 +313,7 @@
}
dom->domid = domid;
-
dom->conspath = xs_get_domain_path(xs, dom->domid);
- if (dom->conspath == NULL)
- goto out;
s = realloc(dom->conspath, strlen(dom->conspath) +
strlen("/console") + 1);
if (s == NULL)
@@ -313,7 +321,7 @@
dom->conspath = s;
strcat(dom->conspath, "/console");
- dom->tty_fd = domain_create_tty(dom);
+ dom->tty_fd = -1;
dom->is_dead = false;
dom->buffer.data = 0;
dom->buffer.size = 0;
@@ -419,10 +427,14 @@
char msg[80];
int i;
struct xencons_interface *intf = dom->interface;
- XENCONS_RING_IDX filled = intf->in_prod - intf->in_cons;
-
- if (sizeof(intf->in) > filled)
- len = sizeof(intf->in) - filled;
+ XENCONS_RING_IDX cons, prod;
+
+ cons = intf->in_cons;
+ prod = intf->in_prod;
+ mb();
+
+ if (sizeof(intf->in) > (prod - cons))
+ len = sizeof(intf->in) - (prod - cons);
if (len > sizeof(msg))
len = sizeof(msg);
@@ -441,10 +453,11 @@
}
} else if (domain_is_valid(dom->domid)) {
for (i = 0; i < len; i++) {
- intf->in[MASK_XENCONS_IDX(intf->in_prod, intf->in)] =
+ intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
msg[i];
- intf->in_prod++;
- }
+ }
+ wmb();
+ intf->in_prod = prod;
evtchn_notify(dom);
} else {
close(dom->tty_fd);
@@ -474,7 +487,7 @@
static void handle_ring_read(struct domain *dom)
{
- u16 v;
+ uint16_t v;
if (!read_sync(dom->evtchn_fd, &v, sizeof(v)))
return;
diff -r ff7c5a791ed5 -r fdea4a967bc7
tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
--- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
Fri Oct 21 19:58:39 2005
+++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
Mon Oct 24 15:08:13 2005
@@ -38,7 +38,7 @@
#include <xenctrl.h>
#define TRACE_ENTER /* printf("enter %s\n", __FUNCTION__) */
|