From dd401e2b9250e3bb07ef388ddccbbf80aa106fc7 Mon Sep 17 00:00:00 2001 From: Hongjie Yang Date: Tue, 9 Jan 2007 10:18:36 +0100 Subject: [PATCH 1/6] [S390] memory detection misses 128k. Fix a memory leak problem in the memory detection routines. A memory leak of 128k occurs when we have a contiguous memory with mixed access-mode (read or write) ranges. Signed-off-by: Hongjie Yang Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/head31.S | 12 +++++++++++- arch/s390/kernel/head64.S | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/s390/kernel/head31.S b/arch/s390/kernel/head31.S index 4388b3309e0c..eca507050e47 100644 --- a/arch/s390/kernel/head31.S +++ b/arch/s390/kernel/head31.S @@ -164,11 +164,14 @@ startup_continue: srl %r7,28 clr %r6,%r7 # compare cc with last access code be .Lsame-.LPG1(%r13) - b .Lchkmem-.LPG1(%r13) + lhi %r8,0 # no program checks + b .Lsavchk-.LPG1(%r13) .Lsame: ar %r5,%r1 # add 128KB to end of chunk bno .Lloop-.LPG1(%r13) # r1 < 0x80000000 -> loop .Lchkmem: # > 2GB or tprot got a program check + lhi %r8,1 # set program check flag +.Lsavchk: clr %r4,%r5 # chunk size > 0? be .Lchkloop-.LPG1(%r13) st %r4,0(%r3) # store start address of chunk @@ -190,8 +193,15 @@ startup_continue: je .Ldonemem # if not, leave chi %r10,0 # do we have chunks left? je .Ldonemem + chi %r8,1 # program check ? + je .Lpgmchk + lr %r4,%r5 # potential new chunk + alr %r5,%r1 # add 128KB to end of chunk + j .Llpcnt +.Lpgmchk: alr %r5,%r1 # add 128KB to end of chunk lr %r4,%r5 # potential new chunk +.Llpcnt: clr %r5,%r9 # should we go on? jl .Lloop .Ldonemem: diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S index c526279e1123..6ba3f4512dd1 100644 --- a/arch/s390/kernel/head64.S +++ b/arch/s390/kernel/head64.S @@ -172,12 +172,15 @@ startup_continue: srl %r7,28 clr %r6,%r7 # compare cc with last access code je .Lsame - j .Lchkmem + lghi %r8,0 # no program checks + j .Lsavchk .Lsame: algr %r5,%r1 # add 128KB to end of chunk # no need to check here, brc 12,.Lloop # this is the same chunk .Lchkmem: # > 16EB or tprot got a program check + lghi %r8,1 # set program check flag +.Lsavchk: clgr %r4,%r5 # chunk size > 0? je .Lchkloop stg %r4,0(%r3) # store start address of chunk @@ -204,8 +207,15 @@ startup_continue: chi %r10, 0 # do we have chunks left? je .Ldonemem .Lhsaskip: + chi %r8,1 # program check ? + je .Lpgmchk + lgr %r4,%r5 # potential new chunk + algr %r5,%r1 # add 128KB to end of chunk + j .Llpcnt +.Lpgmchk: algr %r5,%r1 # add 128KB to end of chunk lgr %r4,%r5 # potential new chunk +.Llpcnt: clgr %r5,%r9 # should we go on? jl .Lloop .Ldonemem: From 6faf4444f2445b068a4f75a86ae81b104c0eed2c Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 9 Jan 2007 10:18:41 +0100 Subject: [PATCH 2/6] [S390] cio: use barrier() in stsch_reset. Use barrier() in stsch_reset() instead of duplicating the stsch() inline assembly and adding "memory" to the clobberlist. Pointed out by Chuck Ebbert. Real fix would be to add a fixup section to the stsch() and extend the basic program check handler so it searches the exception tables in case of a program check. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- drivers/s390/cio/cio.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index b471ac4a1bf6..ae1bf231d089 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c @@ -880,19 +880,15 @@ static void cio_reset_pgm_check_handler(void) static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr) { int rc; - register struct subchannel_id reg1 asm ("1") = schid; pgm_check_occured = 0; s390_reset_pgm_handler = cio_reset_pgm_check_handler; - - asm volatile( - " stsch 0(%2)\n" - " ipm %0\n" - " srl %0,28" - : "=d" (rc) - : "d" (reg1), "a" (addr), "m" (*addr) : "memory", "cc"); - + rc = stsch(schid, addr); s390_reset_pgm_handler = NULL; + + /* The program check handler could have changed pgm_check_occured */ + barrier(); + if (pgm_check_occured) return -EIO; else From 6721f77810dfcb7cbf8e97be6fa43fe2740dd0aa Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 9 Jan 2007 10:18:44 +0100 Subject: [PATCH 3/6] [S390] Fix cpu hotplug (missing 'online' attribute). 72486f1f8f0a2bc828b9d30cf4690cf2dd6807fc inverts the logic if an 'online' attribute in /sys/devices/system/cpu/cpuX should appear. So we end up with no hotpluggable cpus at all... Set the hotpluggable value to one to make sure the online attribute appears again. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/smp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 19090f7d4f51..c0cd255fddbd 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -794,7 +794,10 @@ static int __init topology_init(void) int ret; for_each_possible_cpu(cpu) { - ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu); + struct cpu *c = &per_cpu(cpu_devices, cpu); + + c->hotpluggable = 1; + ret = register_cpu(c, cpu); if (ret) printk(KERN_WARNING "topology_init: register_cpu %d " "failed (%d)\n", cpu, ret); From de338a3795bbcb3c3d77591f65118cbec776cc39 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 9 Jan 2007 10:18:47 +0100 Subject: [PATCH 4/6] [S390] Fix vmalloc area size calculation. setup_memory_end() uses VMALLOC_END instead of VMALLOC_END_INIT to calculate the maximum supported size of physical memory. Since VMALLOC_END is zero, this will cause a crash on 31 bit systems. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 49ef206ec880..5d8ee3baac14 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -476,7 +476,7 @@ static void __init setup_memory_end(void) int i; memory_size = real_size = 0; - max_phys = VMALLOC_END - VMALLOC_MIN_SIZE; + max_phys = VMALLOC_END_INIT - VMALLOC_MIN_SIZE; memory_end &= PAGE_MASK; max_mem = memory_end ? min(max_phys, memory_end) : max_phys; From d8ad075ef60ca33f1bd8e227eed2202108fd6cd8 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 9 Jan 2007 10:18:50 +0100 Subject: [PATCH 5/6] [S390] don't call handle_mm_fault() if in an atomic context. There are several places in the futex code where a spin_lock is held and still uaccesses happen. Deadlocks are avoided by increasing the preempt count. The pagefault handler will then not take any locks but will immediately search the fixup tables. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/lib/uaccess_pt.c | 3 +++ arch/s390/lib/uaccess_std.c | 3 --- include/asm-s390/futex.h | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c index 633249c3ba91..49c3e46b4065 100644 --- a/arch/s390/lib/uaccess_pt.c +++ b/arch/s390/lib/uaccess_pt.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -18,6 +19,8 @@ static inline int __handle_fault(struct mm_struct *mm, unsigned long address, struct vm_area_struct *vma; int ret = -EFAULT; + if (in_atomic()) + return ret; down_read(&mm->mmap_sem); vma = find_vma(mm, address); if (unlikely(!vma)) diff --git a/arch/s390/lib/uaccess_std.c b/arch/s390/lib/uaccess_std.c index bbaca66fa293..56a0214e9928 100644 --- a/arch/s390/lib/uaccess_std.c +++ b/arch/s390/lib/uaccess_std.c @@ -258,8 +258,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old) { int oldval = 0, newval, ret; - pagefault_disable(); - switch (op) { case FUTEX_OP_SET: __futex_atomic_op("lr %2,%5\n", @@ -284,7 +282,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old) default: ret = -ENOSYS; } - pagefault_enable(); *old = oldval; return ret; } diff --git a/include/asm-s390/futex.h b/include/asm-s390/futex.h index 5e261e1de671..5c5d02de49e9 100644 --- a/include/asm-s390/futex.h +++ b/include/asm-s390/futex.h @@ -4,8 +4,8 @@ #ifdef __KERNEL__ #include +#include #include -#include static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) { @@ -21,7 +21,9 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) return -EFAULT; + pagefault_disable(); ret = uaccess.futex_atomic_op(op, uaddr, oparg, &oldval); + pagefault_enable(); if (!ret) { switch (cmp) { From bf3dbdcd0bfca74c16ad0b2b5a978907c864ed4c Mon Sep 17 00:00:00 2001 From: Christian Borntraeger Date: Tue, 9 Jan 2007 10:19:03 +0100 Subject: [PATCH 6/6] [S390] locking problem with __cpcmd. Changeset 740b5706b9c4b3767f597b3ea76654c6f2a800b2 moved the protecting spinlock from __cpcmd to cpcmd. Therefore vmcp can no longer use __cpcmd, instead we have to use cpcmd. Signed-off-by: Christian Borntraeger Signed-off-by: Martin Schwidefsky --- drivers/s390/char/vmcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c index 1678b6c757ec..a420cd099041 100644 --- a/drivers/s390/char/vmcp.c +++ b/drivers/s390/char/vmcp.c @@ -117,7 +117,7 @@ vmcp_write(struct file *file, const char __user * buff, size_t count, return -ENOMEM; } debug_text_event(vmcp_debug, 1, cmd); - session->resp_size = __cpcmd(cmd, session->response, + session->resp_size = cpcmd(cmd, session->response, session->bufsize, &session->resp_code); up(&session->mutex);