genode/ports-foc/patches/l4lx_genode.patch
Stefan Kalkowski f4e0230dde L4lx: mask all VCPU IRQs when doing ipc (fix #553)
Open VCPU interrupts while the VCPU is in an IPC operation can badly influence
its state. That's why this commit fixes a whole bunch of places, where IRQs
weren't masked by now.
2012-12-18 09:31:46 +01:00

1161 lines
30 KiB
Diff

Index: arch/l4/boot/Makefile
===================================================================
--- arch/l4/boot/Makefile (revision 25)
+++ arch/l4/boot/Makefile (working copy)
@@ -10,7 +10,7 @@
$(call if_changed,objcopy)
@echo ' Kernel: $@ is ready'
-lImage: $(obj)/Image vmlinuz$(VMLINUZ_SUFFIX) l4linux$(VMLINUZ_SUFFIX)
+lImage: $(obj)/Image
vmlinuz$(VMLINUZ_SUFFIX): ldrImage FORCE
$(call if_changed,gzip)
@@ -21,8 +21,8 @@
objects-y := ldr.o res.o image.o
-include $(L4OBJ)/l4defs.mk.inc
-
+#include $(L4OBJ)/l4defs.mk.inc
+KBUILD_CFLAGS_i386 = -m32
KBUILD_CFLAGS := $(filter-out -mregparm=3,$(KBUILD_CFLAGS)) \
$(L4INC) -I$(L4OBJ)/include/uclibc \
-Wall -fno-strict-aliasing -O2 -pipe \
Index: arch/l4/lib/pte.c
===================================================================
--- arch/l4/lib/pte.c (revision 25)
+++ arch/l4/lib/pte.c (working copy)
@@ -18,7 +18,10 @@
#include <l4/sys/task.h>
#include <l4/sys/kdebug.h>
#include <l4/re/consts.h>
+#include <l4/log/log.h>
+extern void l4lx_memory_map_physical_page(unsigned long address);
+
static void l4x_flush_page(struct mm_struct *mm,
unsigned long address,
unsigned long vaddr,
@@ -77,7 +80,7 @@
if (mm && !l4_is_invalid_cap(mm->context.task)) {
L4XV_V(f);
if (!mm->context.task)
- l4x_printf("%s: Ups, task == 0\n", __func__);
+ LOG_printf("%s: Ups, task == 0\n", __func__);
/* Direct flush in the child, use virtual address in the
* child address space */
L4XV_L(f);
@@ -93,10 +96,11 @@
tag = l4_task_unmap(L4RE_THIS_TASK_CAP,
l4_fpage(address & PAGE_MASK, size, flush_rights),
L4_FP_OTHER_SPACES);
+ l4lx_memory_map_physical_page(address);
L4XV_U(f);
}
if (l4_error(tag))
- l4x_printf("l4_task_unmap error %ld\n", l4_error(tag));
+ LOG_printf("l4_task_unmap error %ld\n", l4_error(tag));
}
#ifdef ARCH_arm
Index: arch/l4/Makefile
===================================================================
--- arch/l4/Makefile (revision 25)
+++ arch/l4/Makefile (working copy)
@@ -163,6 +163,14 @@
KBUILD_CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
+#
+# Prevent the gcc from linking Linux functions into compiler-generated
+# Genode stuff.
+#
+KBUILD_CFLAGS += -Dmemmove=lx_memmove -Dmemset=lx_memset -Dmemcpy=lx_memcpy
+KBUILD_CFLAGS += -Dstrlen=lx_strlen -Dabort=lx_abort
+
+
endif
ifeq ($(BASEARCH),arm)
@@ -243,6 +251,8 @@
endif
+# Genode compiler is build without Linux defines.
+KBUILD_CFLAGS +=-D__linux__ -Dlinux
# -----------------------------------------------
@@ -265,14 +275,15 @@
L4LX_E_L-$(CONFIG_L4_TCG_STPM) += stpm-client
L4LX_E_L-$(CONFIG_L4_FERRET) += ferret
-L4INC = -I$(L4OBJ)/include/$(L4_MK_ARCH)/$(L4_MK_API) \
- -I$(L4OBJ)/include/$(L4_MK_ARCH) \
- -I$(L4OBJ)/include/$(L4_MK_API) \
- -I$(L4OBJ)/include
+#L4INC = -I$(L4OBJ)/include/$(L4_MK_ARCH)/$(L4_MK_API) \
+# -I$(L4OBJ)/include/$(L4_MK_ARCH) \
+# -I$(L4OBJ)/include/$(L4_MK_API) \
+# -I$(L4OBJ)/include
head-y := arch/l4/kernel/head.o
-libs-y += arch/l4/lib/arch-$(BASEARCH)/ \
+libs-y += arch/l4/lib/arch-$(BASEARCH)/
+#\
arch/l4/l4lxlib/generic/ \
arch/l4/l4lxlib/$(BASEENV)/
@@ -291,7 +302,7 @@
core-y += arch/l4/
--include $(L4OBJ)/l4defs.mk.inc
+#-include $(L4OBJ)/l4defs.mk.inc
L4_REQUIRED_MODS := libc_be_minimal_log_io \
libc_minimal libc_minimal_l4re \
@@ -307,15 +318,17 @@
$(error Aborting.)
endif
-libs-y += -Bstatic $(L4_LIBDIRS) -ll4sys -ll4sys-direct -lgcc-l4
+libs-y += -Bstatic $(L4_LIBDIRS)
+#-ll4sys -ll4sys-direct -lgcc-l4
+libs-y += $(GENODE_LIBS)
export L4INC L4_REQUIRED_MODS
-LDFLAGS_vmlinux = \
- --defsym __L4_KIP_ADDR__=$(L4_BID_KIP_ADDR) \
+LDFLAGS_vmlinux = -nostdlib
+# --defsym __L4_KIP_ADDR__=$(L4_BID_KIP_ADDR) \
--defsym __l4sys_invoke_direct=$(L4_BID_KIP_ADDR)+$(L4_BID_KIP_OFFS_SYS_INVOKE) \
--defsym __l4sys_debugger_direct=$(L4_BID_KIP_ADDR)+$(L4_BID_KIP_OFFS_SYS_DEBUGGER)
-KBUILD_CPPFLAGS += -Iarch/l4/include/asm/l4-arch \
+KBUILD_CPPFLAGS += $(GENODE_INCLUDES) -Iarch/l4/include/asm/l4-arch \
-Iarch/$(LINSRCARCH)/include/generated \
$(if $(PLATFORMNAME),-I$(src)/arch/l4/include/asm/mach-$(LINSRCARCH)/$(PLATFORMNAME)) \
$(if $(PLATFORMNAME),-I$(src)/arch/l4/include/asm/plat-$(LINSRCARCH)/$(PLATFORMNAME)) \
@@ -337,6 +350,8 @@
KBUILD_CPPFLAGS += -DTEXT_OFFSET=0x01000000
endif
+drivers-y += arch/l4/drivers/
+
all: lImage
boot := arch/l4/boot
@@ -345,11 +360,11 @@
$(Q)$(MAKE) $(build)=$(boot) $@
check_for_l4defs:
- $(Q)if [ ! -e $(L4OBJ)/l4defs.mk.inc ]; then \
- echo "No $(L4OBJ)/l4defs.mk.inc available."; \
- echo "Did you run 'make' in $(L4OBJ) to a successful end?"; \
- exit 1; \
- fi
+# $(Q)if [ ! -e $(L4OBJ)/l4defs.mk.inc ]; then \
+# echo "No $(L4OBJ)/l4defs.mk.inc available."; \
+# echo "Did you run 'make' in $(L4OBJ) to a successful end?"; \
+# exit 1; \
+# fi
server:
$(Q)$(MAKE) $(build)=arch/l4/server
Index: arch/l4/Kconfig
===================================================================
--- arch/l4/Kconfig (revision 25)
+++ arch/l4/Kconfig (working copy)
@@ -235,6 +235,20 @@
help
Support for (virtual) TPMs provided by the L4 service STPM of TUD:OS.
+config SCREEN_GENODE
+ bool
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
+ default y
+
+config SERIAL_GENODE
+ bool
+ default y
+ select SERIAL_CORE
+ select SERIAL_CORE_CONSOLE
+
+
endmenu # stub drivers
menu "Debugging options"
Index: arch/l4/kernel/dispatch.c
===================================================================
--- arch/l4/kernel/dispatch.c (revision 25)
+++ arch/l4/kernel/dispatch.c (working copy)
@@ -271,7 +271,7 @@
return 0;
if (l4_msgtag_is_page_fault(tag)) {
- l4x_printf("HYBRID PF!!\n");
+ LOG_printf("HYBRID PF!!\n");
/* No exception IPC, it's a page fault, but shouldn't happen */
goto out_fail;
}
@@ -695,7 +695,7 @@
enter_kdebug("non hybrid in idle?!");
} else {
if (unlikely(l4x_handle_async_event(label, utcb, tag)))
- l4x_printf("Async return with error\n");
+ LOG_printf("Async return with error\n");
}
}
}
Index: arch/l4/kernel/arch-arm/traps.c
===================================================================
--- arch/l4/kernel/arch-arm/traps.c (revision 25)
+++ arch/l4/kernel/arch-arm/traps.c (working copy)
@@ -68,6 +68,7 @@
dump_mem("", "Exception stack", frame + 4, frame + 4 + sizeof(struct pt_regs));
}
+#if 0
#ifndef CONFIG_ARM_UNWIND
/*
* Stack pointers should always be within the kernels view of
@@ -83,6 +84,7 @@
return 0;
}
#endif
+#endif
/*
* Dump out the contents of some memory nicely...
@@ -172,6 +174,7 @@
#else
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
{
+#if 0
unsigned int fp, mode;
int ok = 1;
@@ -203,6 +206,7 @@
if (ok)
c_backtrace(fp, mode);
+#endif
}
#endif
Index: arch/l4/kernel/arch-arm/vmlinux.lds.S
===================================================================
--- arch/l4/kernel/arch-arm/vmlinux.lds.S (revision 25)
+++ arch/l4/kernel/arch-arm/vmlinux.lds.S (working copy)
@@ -47,6 +47,12 @@
jiffies = jiffies_64 + 4;
#endif
+PHDRS
+{
+ ro PT_LOAD;
+ rw PT_LOAD;
+}
+
SECTIONS
{
/*
@@ -82,14 +88,32 @@
}
#ifdef CONFIG_XIP_KERNEL
- . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
+ . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) - 4096;
#else
- . = PAGE_OFFSET + TEXT_OFFSET;
+ . = PAGE_OFFSET + TEXT_OFFSET - 4096;
#endif
+
+ .parent : {
+ /*
+ * Leave space for parent capability parameters at start of data
+ * section. The protection domain creator is reponsible for storing
+ * sane values here.
+ */
+ _parent_cap = .;
+ _parent_cap_thread_id = .;
+ LONG(0xffffffff);
+ _parent_cap_local_name = .;
+ LONG(0xffffffff);
+ } : rw
+
+ . = ALIGN(4096);
+
.head.text : {
+ _prog_img_beg = .;
_text = .;
HEAD_TEXT
}
+
.text : { /* Real text segment */
_stext = .; /* Text and read-only data */
__exception_text_start = .;
@@ -104,6 +128,7 @@
#ifdef CONFIG_MMU
*(.fixup)
#endif
+ *(.text.*) /* put all Genode .text entries in here */
*(.gnu.warning)
*(.glue_7)
*(.glue_7t)
@@ -136,6 +161,42 @@
}
#endif
+ /*
+ * When building L4Linux for Genode, the 'CONFIG_ARM_UNWIND' option is
+ * disabled to avoid conflicts between unwinding-related symbols provided
+ * by the Linux kernel and the C++ compiler's libsupc++. Hence, the linker
+ * script section above is not used. Instead, the '.ARM.exidx' entries are
+ * handled as follows (taken from the Genode linker script.
+ */
+ /* .ARM.exidx is sorted, so has to go in its own output section */
+ __exidx_start = .;
+ .ARM.exidx : {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ }
+ __exidx_end = .;
+
+ .ARM.extab : {
+ *(.ARM.extab*)
+ } : rw
+
+ /* exception frames for C++ */
+ .eh_frame : {
+ __eh_frame_start__ = .;
+ KEEP (*(.eh_frame))
+ LONG(0)
+ } : rw
+
+ .init_array : {
+ __init_array_start = .;
+ _ctors_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+ _ctors_end = .;
+ _dtors_start = .;
+ _dtors_end = .;
+ }
+
_etext = .; /* End of text and rodata section */
#ifndef CONFIG_XIP_KERNEL
@@ -240,8 +301,10 @@
DATA_DATA
CONSTRUCTORS
+ *(.data.*) /* put all Genode .data entries in here */
+
_edata = .;
- }
+ } : rw
_edata_loc = __data_loc + SIZEOF(.data);
#ifdef CONFIG_HAVE_TCM
@@ -303,10 +366,20 @@
NOTES
- BSS_SECTION(0, 0, 0)
+ /* BSS */
+ . = ALIGN(PAGE_SIZE);
+ .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
+ __bss_start = .;
+ *(.bss..page_aligned)
+ *(.bss)
+ *(.bss.*) /* put all Genode .bss entries in here */
+ . = ALIGN(4);
+ __bss_stop = .;
+ }
/* L4: Align to full superpage */
. = ALIGN(1048576);
+ _prog_img_end = .;
_end = .;
STABS_DEBUG
Index: arch/l4/kernel/arch-x86/x86_init.c
===================================================================
--- arch/l4/kernel/arch-x86/x86_init.c (revision 25)
+++ arch/l4/kernel/arch-x86/x86_init.c (working copy)
@@ -42,7 +42,7 @@
struct x86_init_ops x86_init __initdata = {
.resources = {
- .probe_roms = probe_roms,
+ .probe_roms = x86_init_noop,
.reserve_resources = reserve_standard_io_resources,
.memory_setup = l4x_memory_setup,
},
Index: arch/l4/kernel/arch-x86/vmlinux.lds.S
===================================================================
--- arch/l4/kernel/arch-x86/vmlinux.lds.S (revision 25)
+++ arch/l4/kernel/arch-x86/vmlinux.lds.S (working copy)
@@ -33,7 +33,7 @@
#ifdef CONFIG_X86_32
OUTPUT_ARCH(i386)
-ENTRY(phys_startup_32)
+ENTRY(_start)
jiffies = jiffies_64;
#else
OUTPUT_ARCH(i386:x86-64)
@@ -68,15 +68,8 @@
#endif
PHDRS {
- text PT_LOAD FLAGS(5); /* R_E */
- data PT_LOAD FLAGS(6); /* RW_ */
-#ifdef CONFIG_X86_64
-#ifdef CONFIG_SMP
- percpu PT_LOAD FLAGS(6); /* RW_ */
-#endif
- init PT_LOAD FLAGS(7); /* RWE */
-#endif
- note PT_NOTE FLAGS(0); /* ___ */
+ ro PT_LOAD;
+ rw PT_LOAD;
}
SECTIONS
@@ -96,6 +89,29 @@
/*_stext = .;*/
.text : AT(ADDR(.text) - LOAD_OFFSET) {
_text = .;
+ _prog_img_beg = .;
+
+ /*
+ * Leave space for parent capability parameters at start of data
+ * section. The protection domain creator is reponsible for storing
+ * sane values here.
+ */
+ _parent_cap = .;
+ _parent_cap_thread_id = .;
+ LONG(0xffffffff);
+ _parent_cap_local_name = .;
+ LONG(0xffffffff);
+
+ /*
+ * Platform-specific entry for Fiasco.OC.
+ *
+ * PIC-code compiled for Fiasco.OC, needs some PIC-compatible
+ * way to enter the kernel, the fixed address of the kernel
+ * entry code address needs to be found here.
+ */
+ __l4sys_invoke_indirect = .;
+ LONG(0xeacff000);
+
/* bootstrapping code */
HEAD_TEXT
#ifdef CONFIG_X86_32
@@ -111,19 +127,55 @@
ENTRY_TEXT
IRQENTRY_TEXT
*(.fixup)
+ *(.text.*) /* put all Genode .text entries in here */
*(.gnu.warning)
+
+ . = ALIGN(0x08);
+
+ _ctors_start = .;
+ KEEP (*(.ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.init_array)) /* list of constructors specific for ARM eabi */
+ _ctors_end = .;
+ _dtors_start = .;
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ _dtors_end = .;
+
/* End of text section */
_etext = .;
- } :text = 0x9090
+ } : rw
- NOTES :text :note
+ NOTES :rw
- EXCEPTION_TABLE(16) :text = 0x9090
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
#if defined(CONFIG_DEBUG_RODATA)
/* .text should occupy whole number of pages */
. = ALIGN(PAGE_SIZE);
#endif
+
+ /*
+ * because in Genode we collect all data.* entries in the data section
+ * we have to put the per_cpu section before defining the data section
+ * otherwise it's symbols would end up in the data section too.
+ */
+#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
+ PERCPU_SECTION(INTERNODE_CACHE_BYTES)
+#endif
+
+ /*
+ * smp_locks might be freed after init
+ * start/end must be page aligned
+ */
+ . = ALIGN(PAGE_SIZE);
+ .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
+ __smp_locks = .;
+ *(.smp_locks)
+ . = ALIGN(PAGE_SIZE);
+ __smp_locks_end = .;
+ }
+
X64_ALIGN_DEBUG_RODATA_BEGIN
RO_DATA(PAGE_SIZE)
X64_ALIGN_DEBUG_RODATA_END
@@ -151,10 +203,34 @@
/* rarely changed data like cpu maps */
READ_MOSTLY_DATA(INTERNODE_CACHE_BYTES)
+ *(.data.*) /* put all Genode .data entries in here */
+
+
/* End of data section */
_edata = .;
- } :data
+ } : rw
+ EXCEPTION_TABLE(16) : rw
+
+ /* exception frames for C++ */
+ .eh_frame : {
+ __eh_frame_start__ = .;
+ KEEP (*(.eh_frame))
+ LONG(0)
+ } : rw
+
+ .init_array : {
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+ }
+
+ .gcc_except_table : {
+ KEEP(*(.gcc_except_table))
+ KEEP(*(.gcc_except_table.*))
+ }
+
#ifdef CONFIG_X86_64
. = ALIGN(PAGE_SIZE);
@@ -273,10 +349,6 @@
EXIT_DATA
}
-#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
- PERCPU_SECTION(INTERNODE_CACHE_BYTES)
-#endif
-
. = ALIGN(PAGE_SIZE);
/* freed after init ends here */
@@ -284,18 +356,6 @@
__init_end = .;
}
- /*
- * smp_locks might be freed after init
- * start/end must be page aligned
- */
- . = ALIGN(PAGE_SIZE);
- .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
- __smp_locks = .;
- *(.smp_locks)
- . = ALIGN(PAGE_SIZE);
- __smp_locks_end = .;
- }
-
#ifdef CONFIG_X86_64
.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
NOSAVE_DATA
@@ -308,6 +368,7 @@
__bss_start = .;
*(.bss..page_aligned)
*(.bss)
+ *(.bss.*) /* put all Genode .bss entries in here */
. = ALIGN(PAGE_SIZE);
__bss_stop = .;
}
@@ -320,6 +381,7 @@
__brk_limit = .;
}
+ _prog_img_end = .;
_end = .;
STABS_DEBUG
Index: arch/l4/kernel/arch-x86/dispatch.c
===================================================================
--- arch/l4/kernel/arch-x86/dispatch.c (revision 25)
+++ arch/l4/kernel/arch-x86/dispatch.c (working copy)
@@ -749,6 +749,7 @@
TBUF_LOG_EXCP(fiasco_tbuf_log_3val("except ", TBUF_TID(t->user_thread_id), t->trap_nr, t->error_code));
+ fiasco_tbuf_log_3val("except ", t->trap_nr, regs->ip, 0);
if (l4x_deliver_signal(r_trapno(t, v), r_err(t, v)))
return 0; /* handled signal, reply */
Index: arch/l4/kernel/timer.c
===================================================================
--- arch/l4/kernel/timer.c (revision 25)
+++ arch/l4/kernel/timer.c (working copy)
@@ -225,12 +225,16 @@
return -ENOMEM;
}
+#if 0
r = L4XV_FN_i(l4_error(l4_factory_create_irq(l4re_env()->factory,
timer_irq_cap)));
if (r) {
printk(KERN_ERR "l4timer: Failed to create irq: %d\n", r);
goto out1;
}
+#else
+ l4lx_thread_alloc_irq(timer_irq_cap);
+#endif
if ((irq = l4x_register_irq(timer_irq_cap)) < 0) {
r = -ENOMEM;
@@ -238,6 +242,7 @@
}
printk("l4timer: Using IRQ%d\n", irq);
+ LOG_printf("l4timer: Using IRQ%d\n", irq);
setup_irq(irq, &l4timer_irq);
@@ -279,7 +284,9 @@
l4x_unregister_irq(irq);
out2:
L4XV_FN_v(l4re_util_cap_release(timer_irq_cap));
+#if 0
out1:
+#endif
l4x_cap_free(timer_irq_cap);
return r;
}
Index: arch/l4/kernel/head.S
===================================================================
--- arch/l4/kernel/head.S (revision 25)
+++ arch/l4/kernel/head.S (working copy)
@@ -53,6 +53,7 @@
.previous
#endif
+#ifdef NOT_GENODE
#ifdef ARCH_arm
.section ".text"
.globl _start
@@ -82,6 +83,10 @@
__address_l4lx_kinfo:
.long l4lx_kinfo
.previous
+#endif
+#endif /* NOT_GENODE */
+
+#ifdef ARCH_arm
.section .data.head, "wa"
.p2align 12
ENTRY(swapper_pg_dir)
Index: arch/l4/kernel/main.c
===================================================================
--- arch/l4/kernel/main.c (revision 25)
+++ arch/l4/kernel/main.c (working copy)
@@ -209,6 +209,7 @@
static void *l4x_main_memory_start;
static void *l4x_isa_dma_memory_start;
unsigned long l4x_vmalloc_memory_start;
+unsigned long l4x_vmalloc_memory_size;
l4_kernel_info_t *l4lx_kinfo;
l4_cap_idx_t l4x_user_gate[NR_CPUS];
@@ -381,6 +382,28 @@
}
+static spinlock_t migrate_lock;
+
+void l4x_irq_save(unsigned long *flags) { local_irq_save(*flags); }
+void l4x_irq_restore(unsigned long flags) { local_irq_restore(flags); }
+unsigned long l4x_hz(void) { return HZ; }
+int l4x_nr_irqs(void) { return NR_IRQS; }
+void l4x_migrate_lock(unsigned long *flags) { spin_lock_irqsave(&migrate_lock, *flags); }
+void l4x_migrate_unlock(unsigned long flags) { spin_unlock_irqrestore(&migrate_lock, flags);}
+unsigned l4x_smp_processor_id() { return smp_processor_id(); }
+
+
+unsigned l4x_target_cpu(const struct cpumask *dest)
+{
+ if (!cpumask_intersects(dest, cpu_online_mask))
+ return (unsigned) -1;
+ return cpumask_any_and(dest, cpu_online_mask);
+}
+
+void l4x_cpumask_copy(struct irq_data *data, const struct cpumask *dest) {
+ cpumask_copy(data->affinity, dest); }
+
+
unsigned long l4x_virt_to_phys(volatile void * address)
{
int i;
@@ -405,10 +428,10 @@
/* Debugging check: don't miss a translation, can give nasty
* DMA problems */
- l4x_printf("%s: Could not translate virt. address %p\n",
+ LOG_printf("%s: Could not translate virt. address %p\n",
__func__, address);
- l4x_virt_to_phys_show();
- WARN_ON(1);
+ //l4x_virt_to_phys_show();
+ //WARN_ON(1);
return __pa(address);
}
@@ -439,7 +462,7 @@
/* Debugging check: don't miss a translation, can give nasty
* DMA problems */
- l4x_printf("%s: Could not translate phys. address 0x%lx\n",
+ LOG_printf("%s: Could not translate phys. address 0x%lx\n",
__func__, address);
l4x_virt_to_phys_show();
WARN_ON(1);
@@ -558,7 +581,7 @@
r = l4re_ns_query_srv(entry->cap, n + 1, *cap);
if (r) {
- l4x_printf("Failed to query name '%s': %s(%d)\n",
+ LOG_printf("Failed to query name '%s': %s(%d)\n",
name, l4sys_errtostr(r), r);
L4XV_U(f);
return -ENOENT;
@@ -742,6 +765,7 @@
= sizeof(at_exit_functions) / sizeof(at_exit_functions[0]);
static int __current_exititem;
+#if 0
static struct cxa_atexit_item *__next_atexit(void)
{
if (__current_exititem >= at_exit_nr_of_functions) {
@@ -750,21 +774,10 @@
}
return &at_exit_functions[__current_exititem++];
}
+#endif
-int __cxa_atexit(void (*f)(void *), void *arg, void *dso_handle)
-{
- struct cxa_atexit_item *h = __next_atexit();
+extern int __cxa_atexit(void (*f)(void *), void *arg, void *dso_handle);
- if (!h)
- return -1;
-
- h->f = f;
- h->arg = arg;
- h->dso_handle = dso_handle;
-
- return 0;
-}
-
void __cxa_finalize(void *dso_handle)
{
const int verbose = 0;
@@ -819,10 +832,20 @@
}
static int l4x_forward_pf(l4_umword_t addr, l4_umword_t pc, int extra_write)
{
+#if 0
l4_msgtag_t tag;
l4_umword_t err;
l4_utcb_t *u = l4_utcb();
+#endif
+ if (!extra_write)
+ l4_touch_ro((void*)l4_trunc_page(addr), L4_LOG2_PAGESIZE);
+ else
+ l4_touch_rw((void*)l4_trunc_page(addr), L4_LOG2_PAGESIZE);
+
+ // TODO: Reenable this part
+#if 0
+
do {
l4_msg_regs_t *mr = l4_utcb_mr_u(u);
mr->mr[0] = addr | (extra_write ? 2 : 0);
@@ -844,6 +867,7 @@
// unresolvable page fault, we're supposed to trigger an
// exception
return 0;
+#endif
return 1;
}
@@ -1283,15 +1307,17 @@
0, "Main memory");
/* Reserve some part of the virtual address space for vmalloc */
- l4x_vmalloc_memory_start = (unsigned long)l4x_main_memory_start;
- if (l4re_rm_reserve_area(&l4x_vmalloc_memory_start,
+ l4x_vmalloc_memory_start = (unsigned long)l4x_main_memory_start + l4x_mainmem_size;
#ifdef CONFIG_X86_32
- __VMALLOC_RESERVE,
+ l4x_vmalloc_memory_size = __VMALLOC_RESERVE;
#elif defined(CONFIG_X86_64)
- VMALLOC_END - VMALLOC_START + 1,
+ l4x_vmalloc_memory_size = VMALLOC_END - VMALLOC_START + 1;
#else
- VMALLOC_SIZE << 20,
+ l4x_vmalloc_memory_size = VMALLOC_SIZE << 20;
#endif
+
+ if (l4re_rm_reserve_area(&l4x_vmalloc_memory_start,
+ l4x_vmalloc_memory_size,
L4RE_RM_SEARCH_ADDR, PGDIR_SHIFT)) {
LOG_printf("%s: Error reserving vmalloc memory area!\n", __func__);
l4x_exit_l4linux();
@@ -1305,7 +1331,7 @@
#ifdef ARCH_x86
// fixmap area
- l4x_fixmap_space_start = (unsigned long)l4x_main_memory_start;
+ l4x_fixmap_space_start = (unsigned long)l4x_vmalloc_memory_start + l4x_vmalloc_memory_size;
if (l4re_rm_reserve_area(&l4x_fixmap_space_start,
__end_of_fixed_addresses * PAGE_SIZE,
L4RE_RM_SEARCH_ADDR, PAGE_SHIFT) < 0) {
@@ -1416,6 +1442,10 @@
static void l4x_create_ugate(l4_cap_idx_t forthread, unsigned cpu)
{
+ LOG_printf("thread=%lx cpu=%x\n", forthread, cpu);
+ l4x_user_gate[cpu] = forthread;
+
+#if 0
l4_msgtag_t r;
l4x_user_gate[cpu] = l4x_cap_alloc_noctx();
@@ -1436,6 +1466,7 @@
l4_debugger_set_object_name(l4x_user_gate[cpu], n);
#endif
}
+#endif
}
#ifdef CONFIG_HOTPLUG_CPU
@@ -1641,11 +1672,15 @@
l4x_exit_l4linux();
}
+#if 0
t = l4_factory_create_irq(l4re_env()->factory, c);
if (l4_error(t)) {
LOG_printf("Failed to create IRQ\n");
l4x_exit_l4linux();
}
+#else
+ l4lx_thread_alloc_irq(c);
+#endif
#ifdef CONFIG_L4_DEBUG_REGISTER_NAMES
l4_debugger_set_object_name(c, s);
@@ -1906,8 +1941,12 @@
static int l4x_cpu_virt_phys_map_init(const char *boot_command_line)
{
+#ifdef CONFIG_SMP
l4_umword_t max_cpus = 1;
+#if 0
l4_sched_cpu_set_t cs = l4_sched_cpu_set(0, 0, 0);
+#endif
+#endif
unsigned i;
#ifdef CONFIG_SMP
@@ -1923,9 +1962,10 @@
}
}
-
+#if 0
if (l4_error(l4_scheduler_info(l4re_env()->scheduler,
&max_cpus, &cs)) == L4_EOK) {
+#endif
if ((p = strstr(boot_command_line, "l4x_cpus_map="))) {
// l4x_cpus_map=0,1,2,3,4,...
// the list specifies the physical CPU for each
@@ -1947,10 +1987,12 @@
LOG_printf("ERROR: Error parsing l4x_cpus_map option\n");
return 1;
}
+#if 0
if (!l4x_cpu_check_pcpu(pcpu, max_cpus)) {
LOG_printf("ERROR: pCPU%d not found\n", pcpu);
return 1;
}
+#endif
l4x_cpu_physmap[l4x_nr_cpus].phys_id = pcpu;
for (i = 0; i < l4x_nr_cpus; ++i)
overbooking |=
@@ -1974,12 +2016,16 @@
l4x_nr_cpus = v;
}
+#if 0
}
+#endif
#ifndef CONFIG_L4_VCPU
l4x_tamed_set_mapping(0, l4x_cpu_physmap_get_id(0));
#endif
#else /* UP */
+
+#if 0
if (l4_error(l4_scheduler_info(l4re_env()->scheduler,
&max_cpus, &cs)) == L4_EOK) {
@@ -1989,6 +2035,8 @@
l4x_cpu_physmap[0].phys_id = p;
}
#endif
+ l4x_cpu_physmap[0].phys_id = 0;
+#endif
LOG_printf("CPU mapping (l:p)[%d]: ", l4x_nr_cpus);
for (i = 0; i < l4x_nr_cpus; i++)
@@ -2034,6 +2082,7 @@
printk("panic: going to sleep forever, bye\n");
L4XV_L(f);
LOG_printf("panic: going to sleep forever, bye\n");
+ enter_kdebug("PANIC");
l4_sleep_forever();
return 0;
}
@@ -2302,7 +2351,7 @@
LOG_printf("Device scan done.\n");
}
-int __init_refok L4_CV main(int argc, char **argv)
+int __init_refok L4_CV linux_main(int argc, char **argv)
{
l4lx_thread_t main_id;
struct l4lx_thread_start_info_t si;
@@ -2414,10 +2463,13 @@
l4x_start_thread_id = l4re_env()->main_thread;
+#if 0
l4_thread_control_start();
l4_thread_control_commit(l4x_start_thread_id);
l4x_start_thread_pager_id
= l4_utcb_mr()->mr[L4_THREAD_CONTROL_MR_IDX_PAGER];
+#endif
+ l4x_start_thread_pager_id = l4re_env()->rm;
#ifndef CONFIG_L4_VCPU
#ifdef CONFIG_L4_TAMED
@@ -3223,6 +3275,10 @@
/* Not resolvable: Ooops */
LOG_printf("Non-resolvable page fault at %lx, ip %lx.\n", pfa, ip);
// will trigger an oops in caller
+
+#ifdef CONFIG_L4_DEBUG_SEGFAULTS
+ enter_kdebug("PF");
+#endif
return 0;
}
@@ -3419,7 +3475,9 @@
void exit(int code)
{
__cxa_finalize(0);
+#if 0
l4x_external_exit(code);
+#endif
LOG_printf("Still alive, going zombie???\n");
l4_sleep_forever();
}
Index: arch/l4/include/asm/generic/l4lib.h
===================================================================
--- arch/l4/include/asm/generic/l4lib.h (revision 25)
+++ arch/l4/include/asm/generic/l4lib.h (working copy)
@@ -3,6 +3,7 @@
#include <linux/stringify.h>
+#if 0
#ifdef ARCH_arm
#define L4_EXTERNAL_FUNC(func) \
asm(".section \".data.l4externals.str\" \n" \
@@ -58,5 +59,8 @@
".previous \n" \
)
#endif
+#endif
+#define L4_EXTERNAL_FUNC(func) ;
+
#endif /* __INCLUDE__ASM_L4__GENERIC__L4LIB_H__ */
Index: arch/l4/include/asm/l4lxapi/thread.h
===================================================================
--- arch/l4/include/asm/l4lxapi/thread.h (revision 25)
+++ arch/l4/include/asm/l4lxapi/thread.h (working copy)
@@ -32,6 +32,8 @@
*/
void l4lx_thread_init(void);
+void l4lx_thread_alloc_irq(l4_cap_idx_t c);
+
/**
* \brief Create a thread.
* \ingroup thread
Index: arch/x86/lib/memcpy_32.c
===================================================================
--- arch/x86/lib/memcpy_32.c (revision 25)
+++ arch/x86/lib/memcpy_32.c (working copy)
@@ -1,8 +1,13 @@
#include <linux/string.h>
#include <linux/module.h>
+#ifdef NOT_GENODE
#undef memcpy
#undef memset
+#else
+#undef lx_memcpy
+#undef lx_memset
+#endif /* NOT_GENODE */
void *memcpy(void *to, const void *from, size_t n)
{
Index: arch/x86/include/asm/string_32.h
===================================================================
--- arch/x86/include/asm/string_32.h (revision 25)
+++ arch/x86/include/asm/string_32.h (working copy)
@@ -179,8 +179,12 @@
#ifndef CONFIG_KMEMCHECK
#if (__GNUC__ >= 4)
+#ifdef NOT_GENODE
#define memcpy(t, f, n) __builtin_memcpy(t, f, n)
#else
+#define lx_memcpy(t, f, n) __memcpy(t, f, n)
+#endif
+#else
#define memcpy(t, f, n) \
(__builtin_constant_p((n)) \
? __constant_memcpy((t), (f), (n)) \
@@ -322,8 +326,12 @@
#define __HAVE_ARCH_MEMSET
#if (__GNUC__ >= 4)
+#ifdef NOT_GENODE
#define memset(s, c, count) __builtin_memset(s, c, count)
#else
+#define lx_memset(s, c, count) __memset(s, c, count)
+#endif
+#else
#define memset(s, c, count) \
(__builtin_constant_p(c) \
? __constant_c_x_memset((s), (0x01010101UL * (unsigned char)(c)), \
Index: drivers/tty/serial/l4ser.c
===================================================================
--- drivers/tty/serial/l4ser.c (revision 25)
+++ drivers/tty/serial/l4ser.c (working copy)
@@ -22,10 +22,12 @@
#include <linux/serial.h>
#include <l4/sys/vcon.h>
+#include <l4/sys/kdebug.h>
#include <l4/sys/factory.h>
#include <l4/sys/icu.h>
#include <l4/re/c/namespace.h>
#include <l4/re/c/util/cap.h>
+#include <l4/log/log.h>
#include <asm/generic/setup.h>
#include <asm/generic/cap_alloc.h>
#include <asm/generic/util.h>
@@ -118,7 +120,7 @@
int c;
if (port->x_char) {
- L4XV_FN_v(l4_vcon_write(l4port->vcon_cap, &port->x_char, 1));
+ L4XV_FN_v(l4_vcon_write(LOG_printf("%c", port->x_char));
port->icount.tx++;
port->x_char = 0;
return;
@@ -128,7 +130,12 @@
c = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
if (c > L4_VCON_WRITE_SIZE)
c = L4_VCON_WRITE_SIZE;
- L4XV_FN_v(l4_vcon_write(l4port->vcon_cap, &xmit->buf[xmit->tail], c));
+ L4XV_L(f);
+ char *ptr = (char*)&xmit->buf[xmit->tail], old = ptr[c];
+ ptr[c] = 0;
+ LOG_printf("%s", ptr);
+ ptr[c] = old;
+ L4XV_U(f);
xmit->tail = (xmit->tail + c) & (UART_XMIT_SIZE - 1);
port->icount.tx += c;
}
@@ -247,7 +254,7 @@
if (l4ser_port[num].inited)
return 0;
l4ser_port[num].inited = 1;
-
+#if 0
if ((r = l4x_re_resolve_name(name, &l4ser_port[num].vcon_cap))) {
if (num == 0)
l4ser_port[num].vcon_cap = l4re_env()->log;
@@ -285,7 +292,7 @@
vcon_attr.i_flags = 0;
vcon_attr.o_flags = 0;
vcon_attr.l_flags = 0;
- L4XV_FN_v(l4_vcon_set_attr(l4ser_port[num].vcon_cap, &vcon_attr));
+// L4XV_FN_v(l4_vcon_set_attr(l4ser_port[num].vcon_cap, &vcon_attr));
l4ser_port[num].port.uartclk = 3686400;
l4ser_port[num].port.ops = &l4ser_pops;
@@ -326,7 +333,13 @@
unsigned c = count;
if (c > L4_VCON_WRITE_SIZE)
c = L4_VCON_WRITE_SIZE;
- L4XV_FN_v(l4_vcon_write(l4ser_port[co->index].vcon_cap, s, c));
+ L4XV_L(f);
+ char *ptr = (char*)s, old = ptr[c];
+ ptr[c] = 0;
+ LOG_printf("%s", ptr);
+ ptr[c] = old;
+
+ L4XV_U(f);
count -= c;
} while (count);
}
Index: include/asm-generic/vmlinux.lds.h
===================================================================
--- include/asm-generic/vmlinux.lds.h (revision 25)
+++ include/asm-generic/vmlinux.lds.h (working copy)
@@ -371,6 +371,7 @@
VMLINUX_SYMBOL(__start___modver) = .; \
*(__modver) \
VMLINUX_SYMBOL(__stop___modver) = .; \
+ LONG(0) /* enforce non-zero section size */ \
. = ALIGN((align)); \
VMLINUX_SYMBOL(__end_rodata) = .; \
} \