From patchwork Fri Jun 10 01:42:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9168755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2817760467 for ; Fri, 10 Jun 2016 01:44:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1856528363 for ; Fri, 10 Jun 2016 01:44:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ABF628368; Fri, 10 Jun 2016 01:44:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,HEXHASH_WORD, RCVD_IN_DNSWL_MED autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A01DA28363 for ; Fri, 10 Jun 2016 01:44:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBBT9-0006zm-Bi; Fri, 10 Jun 2016 01:42:43 +0000 Received: from mail-qt0-f171.google.com ([209.85.216.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBBT6-0006mf-Rd for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2016 01:42:41 +0000 Received: by mail-qt0-f171.google.com with SMTP id q45so15166687qtq.1 for ; Thu, 09 Jun 2016 18:42:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c9cfzGzbFjzIWL/f/737GdHI+n8Xw90M8GyquRcY5AI=; b=bbHX2ZcCgReEPDwpYArIEQKlhs5WFltRqkIJAVBu6bihjkedlolnCep3VhwaXZNkqD xmKpIAN/kVbHqYDmNBAj07Oiqbp6Vhq5vyElOWgy384GRJMYqHpzIwNosfLSKJ7q0QMK 6KymaX7ncghO4Go3nX1fvySvFa/FGNpzIwdqrAtiNwxacXeeGsUzmhlVSkVhDQReuewY BtrrXjieHv+w2c1OmKB2wc5KQH1VN04nchHl1+Ipy4Fl4qax1oV9La34J1PnXiM8L5G3 ZosYezO6VmmPTPWPqBI1VpDQKLnNGMgd2JT2g5Swq9LJkXqwwDpdsLMQvt2odftfChsK Ve2g== X-Gm-Message-State: ALyK8tLyx8dJ9AzBOaVf8GhBdQQ/3E7nIaUHwFLssfqrrQecvNnfLGDHCAeUq92pjiipiYVJ X-Received: by 10.237.49.227 with SMTP id 90mr13115010qth.44.1465522939556; Thu, 09 Jun 2016 18:42:19 -0700 (PDT) Received: from labbott-redhat-machine.redhat.com ([2601:602:9800:177f::337f]) by smtp.gmail.com with ESMTPSA id z65sm2488691qkd.36.2016.06.09.18.42.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 18:42:18 -0700 (PDT) From: Laura Abbott To: Ard Biesheuvel , Mark Rutland , Will Deacon , Catalin Marinas Subject: [PATCH] arm64: Handle el1 synchronous instruction aborts cleanly Date: Thu, 9 Jun 2016 18:42:08 -0700 Message-Id: <1465522928-22421-1-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.5.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160609_184241_008994_09F82593 X-CRM114-Status: GOOD ( 10.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laura Abbott , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Executing from a non-executable area gives an ugly message: lkdtm: Performing direct entry EXEC_RODATA lkdtm: attempting ok execution at ffff0000084c0e08 lkdtm: attempting bad execution at ffff000008880700 Bad mode in Synchronous Abort handler detected on CPU2, code 0x8400000e -- IABT (current EL) CPU: 2 PID: 998 Comm: sh Not tainted 4.7.0-rc2+ #13 The 'IABT (current EL)' indicates the error but isn't as obvious as a regular fault message. The increase in kernel page permissions makes hitting this case more likely and bad mode should not be a common ocurrence. Handle this case in the vectors to give a better message. Signed-off-by: Laura Abbott Acked-by: Mark Rutland --- Came up during some lkdtm testing http://article.gmane.org/gmane.linux.kernel.hardened.devel/2524 --- arch/arm64/kernel/entry.S | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 12e8d2b..37f3694 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -336,6 +336,8 @@ el1_sync: lsr x24, x1, #ESR_ELx_EC_SHIFT // exception class cmp x24, #ESR_ELx_EC_DABT_CUR // data abort in EL1 b.eq el1_da + cmp x24, #ESR_ELx_EC_IABT_CUR // instruction abort in EL1 + b.eq el1_ia cmp x24, #ESR_ELx_EC_SYS64 // configurable trap b.eq el1_undef cmp x24, #ESR_ELx_EC_SP_ALIGN // stack alignment exception @@ -347,6 +349,23 @@ el1_sync: cmp x24, #ESR_ELx_EC_BREAKPT_CUR // debug exception in EL1 b.ge el1_dbg b el1_inv +el1_ia: + /* + * Instruction abort handling + */ + mrs x0, far_el1 + enable_dbg + // re-enable interrupts if they were enabled in the aborted context + tbnz x23, #7, 1f // PSR_I_BIT + enable_irq + orr x1, x1, #1 << 24 // use reserved ISS bit for instruction aborts +1: + mov x2, sp // struct pt_regs + bl do_mem_abort + + // disable interrupts before pulling preserved data off the stack + disable_irq + kernel_exit 1 el1_da: /* * Data abort handling