From patchwork Fri Apr 8 12:06:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 8783171 Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EFFB2C0553 for ; Fri, 8 Apr 2016 12:06:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27A0B2027D for ; Fri, 8 Apr 2016 12:06:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0FB1B2026F for ; Fri, 8 Apr 2016 12:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754281AbcDHMGU (ORCPT ); Fri, 8 Apr 2016 08:06:20 -0400 Received: from mout.gmx.net ([212.227.15.18]:58306 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754189AbcDHMGT (ORCPT ); Fri, 8 Apr 2016 08:06:19 -0400 Received: from [155.56.68.219] by 3capp-gmx-bs27.server.lan (via HTTP); Fri, 8 Apr 2016 14:06:09 +0200 MIME-Version: 1.0 Message-ID: From: "Helge Deller" To: "Helge Deller" Cc: "Mikulas Patocka" , "John David Anglin" , linux-parisc@vger.kernel.org Subject: Aw: Re: kernel 4.6-rc unbootable due to module changes Date: Fri, 8 Apr 2016 14:06:09 +0200 Importance: normal Sensitivity: Normal In-Reply-To: <5706E3A0.2020902@gmx.de> References: <570409DA.1060508@gmx.de> <57058332.8050204@gmx.de>, <5706E3A0.2020902@gmx.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K0:XqT4Fr2f0QBVMVCxr19qwWiKgoGuEMc13zvoPWWEE0+ bJ8AsDYBPZCjowi2Dgo5JVf13NQmEi1y6dd0x9B2y5LuXB9QEO nIe7Tus7cGazxzzIbUbU+MChIg4hG2ryPwLUQMHOMJjcgLtLaI jhPrcD88GhQ+pCJw8QvTpZPSa1VtOwQLXkxVnWEUr4bnSfba4b WVLZA+DsvOOSSs5RqqCya1KAxzmDWyUScc2yU+mNARYiuF/CYD Bqa7ilCudNi1QX0tRKxJfmGhKWSK2w7OqGu0K8JMraT5ny3DMi rrkuZk= X-UI-Out-Filterresults: notjunk:1; V01:K0:lZu5kUZFmxM=:Y0XmZ0s9j4nYxr/uHv9C6h nDbX2IfzY2yyJLrwBDWbcY00TFXRSeqBZGvpIcPjhckHRUKR9opaI49uNw7pmRP8zV2jkvL4B nyIKUdvgcPPjZlWCSFSkTUaPvCgOqm9NRiXMwIjmdRxdFvdg7A/5egtxIXWw+v9H78Tn9uJ9P oeJNucvGLFmoE1xJexekxDhjCKP6Xe++joayXrjDWxBEih5dBdMLGxHcLljJ8utT0ykRZYRJb /cgm0k6vOoq+w9zNZ3cgxwbA2Ti80EQ+fBpA2LYP24dJNDo0UCHFs6hVT+UizSR8mWGaGbq/I dyHpoNEhe42hlZV9GcsKE0kLM7tC7ffaenuL2pRLNSowO7MyRPBDl1y+p5GqcubXrH+QrUJ3p zK/56OCP6oJJpkq0FZGAnOCGh/dznRXTedDcGd4hhNB+Wa4nRnKdK4ZnUuVFrL4x9dJWr42m3 N2yr9zX06Q== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_TVD_MIME_EPI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > >> So, it seems that handling exceptions from modules never worked on > >> pa-risc, it was just masked by the fact that exceptions from modules don't > >> happen during normal use. > > Sadly you seem to be right :-( > I did more testing with the test_user_copy module (with vanilla kernel 4.5 and without the relative extable support). The attached patch fixes the exception handling for modules for me. This is realized by saving the %r27 register in the fault handler and restoring it in the exception path. With this patch the "test_user_copy" kernel module succeeds when loaded. Mikulas, can you try it with your testcases ? Helge diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h index 0abdd4c..1b05163 100644 --- a/arch/parisc/include/asm/uaccess.h +++ b/arch/parisc/include/asm/uaccess.h @@ -78,6 +78,7 @@ struct exception_data { unsigned long fault_ip; unsigned long fault_space; unsigned long fault_addr; + unsigned long fault_gp; }; #define __get_user(x, ptr) \ diff --git a/arch/parisc/kernel/asm-offsets.c b/arch/parisc/kernel/asm-offsets.c index d2f6257..137c91e 100644 --- a/arch/parisc/kernel/asm-offsets.c +++ b/arch/parisc/kernel/asm-offsets.c @@ -301,6 +301,7 @@ int main(void) DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip)); DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space)); DEFINE(EXCDATA_ADDR, offsetof(struct exception_data, fault_addr)); + DEFINE(EXCDATA_GP, offsetof(struct exception_data, fault_gp)); BLANK(); DEFINE(ASM_PDC_RESULT_SIZE, NUM_PDC_RESULT * sizeof(unsigned long)); BLANK(); diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c index 568b2c6..3cad8aa 100644 --- a/arch/parisc/kernel/parisc_ksyms.c +++ b/arch/parisc/kernel/parisc_ksyms.c @@ -47,11 +47,11 @@ EXPORT_SYMBOL(__cmpxchg_u64); EXPORT_SYMBOL(lclear_user); EXPORT_SYMBOL(lstrnlen_user); -/* Global fixups */ -extern void fixup_get_user_skip_1(void); -extern void fixup_get_user_skip_2(void); -extern void fixup_put_user_skip_1(void); -extern void fixup_put_user_skip_2(void); +/* Global fixups - defined as int to avoid creation of function pointers */ +extern int fixup_get_user_skip_1; +extern int fixup_get_user_skip_2; +extern int fixup_put_user_skip_1; +extern int fixup_put_user_skip_2; EXPORT_SYMBOL(fixup_get_user_skip_1); EXPORT_SYMBOL(fixup_get_user_skip_2); EXPORT_SYMBOL(fixup_put_user_skip_1); diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c index 553b098..77e2262 100644 --- a/arch/parisc/kernel/traps.c +++ b/arch/parisc/kernel/traps.c @@ -798,6 +798,9 @@ void notrace handle_interruption(int code, struct pt_regs *regs) if (fault_space == 0 && !faulthandler_disabled()) { + /* Clean up and return if in exception table. */ + if (fixup_exception(regs)) + return; pdc_chassis_send_status(PDC_CHASSIS_DIRECT_PANIC); parisc_terminate("Kernel Fault", regs, code, fault_address); } diff --git a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S index 536ef66..1052b74 100644 --- a/arch/parisc/lib/fixup.S +++ b/arch/parisc/lib/fixup.S @@ -26,6 +26,7 @@ #ifdef CONFIG_SMP .macro get_fault_ip t1 t2 + loadgp addil LT%__per_cpu_offset,%r27 LDREG RT%__per_cpu_offset(%r1),\t1 /* t2 = smp_processor_id() */ @@ -40,14 +41,19 @@ LDREG RT%exception_data(%r1),\t1 /* t1 = this_cpu_ptr(&exception_data) */ add,l \t1,\t2,\t1 + /* %r27 = t1->fault_gp - restore gp */ + LDREG EXCDATA_GP(\t1), %r27 /* t1 = t1->fault_ip */ LDREG EXCDATA_IP(\t1), \t1 .endm #else .macro get_fault_ip t1 t2 + loadgp /* t1 = this_cpu_ptr(&exception_data) */ addil LT%exception_data,%r27 LDREG RT%exception_data(%r1),\t2 + /* %r27 = t2->fault_gp - restore gp */ + LDREG EXCDATA_GP(\t2), %r27 /* t1 = t2->fault_ip */ LDREG EXCDATA_IP(\t2), \t1 .endm diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index a762864..245784e 100644 --- a/arch/parisc/mm/fault.c +++ b/arch/parisc/mm/fault.c @@ -153,6 +153,7 @@ int fixup_exception(struct pt_regs *regs) d->fault_ip = regs->iaoq[0]; d->fault_space = regs->isr; d->fault_addr = regs->ior; + d->fault_gp = regs->gr[27]; regs->iaoq[0] = ((fix->fixup) & ~3); /*