From cdf2f55a90e40d6b34db835fc26b83bd03d846c8 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Sun, 23 Jun 2013 18:37:57 +0200 Subject: [PATCH] kernel, arm ucontext: ARM DBG=-g run fixes kernel: . modules can be as big as the space (8MB) between them instead of 4MB; memory is slightly bigger with DBG=-g arm ucontext: . r4 is clobbered by the restore function, as it's used as a scratch register, causing problems for the DBG=-g build . r1-r3 are safe for scratch registers, as they are caller-save, so use r3 instead; and don't bother restoring r1-r3, but preserve r4 vfs: . improve TLL pointer sanity check a bit Change-Id: I0e3cfc367fdc14477e40d04b5e044f288ca4cc7d --- kernel/arch/earm/pre_init.c | 4 ++-- lib/libc/arch/arm/sys-minix/ucontext.S | 9 +++------ servers/vfs/tll.c | 4 +++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/kernel/arch/earm/pre_init.c b/kernel/arch/earm/pre_init.c index 646fb4556..a54f1d3e9 100644 --- a/kernel/arch/earm/pre_init.c +++ b/kernel/arch/earm/pre_init.c @@ -105,7 +105,6 @@ int overlaps(multiboot_module_t *mod, int n, int cmp_mod) #define MB_MODS_BASE 0x82000000 #define MB_PARAM_MOD 0x88000000 #define MB_MODS_ALIGN 0x00800000 /* 8 MB */ -#define MB_MODS_SIZE 0x00400000 /* 4 MB */ #define MB_MMAP_START 0x80000000 #define MB_MMAP_SIZE 0x10000000 /* 256 MB */ @@ -123,7 +122,8 @@ void setup_mbi(multiboot_info_t *mbi) int i; for (i = 0; i < MB_MODS_NR; ++i) { mb_modlist[i].mod_start = MB_MODS_BASE + i * MB_MODS_ALIGN; - mb_modlist[i].mod_end = mb_modlist[i].mod_start + MB_MODS_SIZE ; + mb_modlist[i].mod_end = mb_modlist[i].mod_start + MB_MODS_ALIGN + - ARM_PAGE_SIZE; mb_modlist[i].cmdline = 0; } diff --git a/lib/libc/arch/arm/sys-minix/ucontext.S b/lib/libc/arch/arm/sys-minix/ucontext.S index 9fd6c7ed2..23e951026 100644 --- a/lib/libc/arch/arm/sys-minix/ucontext.S +++ b/lib/libc/arch/arm/sys-minix/ucontext.S @@ -126,9 +126,6 @@ ENTRY(setcontext) pop {r0, r3} 1: /* Restore the registers */ - ldr r1, [r0, #REG1] /* Restore r1 */ - ldr r2, [r0, #REG2] /* Restore r2 */ - ldr r3, [r0, #REG3] /* Restore r3 */ ldr r4, [r0, #REG4] /* Restore r4 */ ldr r5, [r0, #REG5] /* Restore r5 */ ldr r6, [r0, #REG6] /* Restore r6 */ @@ -140,10 +137,10 @@ ENTRY(setcontext) ldr fp, [r0, #FPREG] /* Restore fp */ ldr sp, [r0, #SPREG] /* Restore sp */ ldr lr, [r0, #LRREG] /* Restore lr */ - mov r4, r0 - ldr r0, [r4, #REG0] /* Restore r0 */ + mov r3, r0 + ldr r0, [r3, #REG0] /* Restore r0 */ 2: - ldr pc, [r4, #PCREG] /* Restore pc */ + ldr pc, [r3, #PCREG] /* Restore pc */ /* void ctx_start() diff --git a/servers/vfs/tll.c b/servers/vfs/tll.c index 93c2ea7fa..c7fa0de1b 100644 --- a/servers/vfs/tll.c +++ b/servers/vfs/tll.c @@ -125,11 +125,13 @@ void tll_init(tll_t *tllp) int tll_islocked(tll_t *tllp) { + assert(tllp >= (tll_t *) PAGE_SIZE); return(tllp->t_current != TLL_NONE); } int tll_locked_by_me(tll_t *tllp) { + assert(tllp >= (tll_t *) PAGE_SIZE); assert(self != NULL); return(tllp->t_owner == self && !(tllp->t_status & TLL_PEND)); } @@ -139,7 +141,7 @@ int tll_lock(tll_t *tllp, tll_access_t locktype) /* Try to lock three-level-lock tll with type locktype */ assert(self != NULL); - assert(tllp != NULL); + assert(tllp >= (tll_t *) PAGE_SIZE); assert(locktype != TLL_NONE); self->w_next = NULL;