From patchwork Thu Feb 16 01:54:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9576187 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 09D5C600C5 for ; Thu, 16 Feb 2017 01:54:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF2952857E for ; Thu, 16 Feb 2017 01:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0B8128587; Thu, 16 Feb 2017 01:54:49 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CA14A2857E for ; Thu, 16 Feb 2017 01:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=/LUal7g2oG6NiEcJcWkVLjCUkch2qG1Vk+pu9VzfZcw=; b=WYP RyBTeBhRDVWe9EknzKWp2RHct4LvM/ouvz5Gu8OLPG/bm9STjJoG4P7BBZUKt9TZIJvJl2OZUKJig GZ/vdRRvi/6birZs2Ka+9nNLhbjDwnKERIU5wPYCV5lcu4omcoHrFgj5VqPS8hvhz+vnWR9ULFD+7 9bpLHAZFXZWV6hyeW6KVeoKrEQ103jv9KiVPoXjKVMoSH2qgMf5pLjYvYBqOMbH71vXR/o4VQ91vh 4gchkmrFwEzZZcZkS+wOvtGmV8+DI6a7nvwvDIyC5zL3znqx7cad/L6y6krLQ3/MGL2Ma3dtzu+4g aP0CZLpem2Vllg5KNVh6IZBp/Db7ZXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ceBHK-0000Hn-89; Thu, 16 Feb 2017 01:54:38 +0000 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ceBHF-0000GZ-CJ for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2017 01:54:35 +0000 Received: by mail-pg0-x231.google.com with SMTP id t188so1421310pgt.2 for ; Wed, 15 Feb 2017 17:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RUIY/eoBSX//AfEfJY92SsBnKFSBm7+wh8umwvHxU4s=; b=hmItL10e3PHWsp8yd0isO2Dru6vm0U1HhMWvUnl0JQIZ66fUJRdvF12V83bTgYr5IG Nkd99p9PxdZLLINioaHA+WqmbMqd2ZhXs2IgBaqUT0eqURymyVLB5FzGje1Ox+NejxS1 bjgfOBJbn3I0CwFDGvi8YU1gtxxrHCU9RNSLs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RUIY/eoBSX//AfEfJY92SsBnKFSBm7+wh8umwvHxU4s=; b=Z0bvc6GlbdH5qpFxoj9eUdWdyiZDmmJW4SH3H0uPciAwqU57dydJiRuopDQ9Jl1nZE aMsWRV/3EWQG6Ilmyi/ymSTEXjcz1bgPoPmV5A+Kv/fpzPmMer0D3EzptRPxiF59At3A N/m0wWYDMoL+/aU9JvfoH9Kq+N5ivXzVa0Q/zK026UAhtPuXW1gq7PT9XRpewKjB7lNA l7DMFFv/a1gc0mLhxVBTicUkOjUtUDgH88N/RqBPC2E2P5TYPtMUrqW6MYyN8w9tXlhN T4qNPlDXdUqMCBSVP3YioD0s8bctn3yN8ydZRL0mtcdyysbL7SssO1IhluaeqPo6fACN e7JA== X-Gm-Message-State: AMke39nv0sD+FagzcloH6MDhdBqImaEgM6jKwZRlZaMdedLc7UThwBAFpbFNRLJ4gtrZSGnn X-Received: by 10.84.136.75 with SMTP id 69mr48326004plk.172.1487210049951; Wed, 15 Feb 2017 17:54:09 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 188sm9651065pfg.99.2017.02.15.17.54.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Feb 2017 17:54:09 -0800 (PST) From: Stephen Boyd To: Catalin Marinas , Will Deacon Subject: [PATCH] arm64: print a fault message when attempting to write RO memory Date: Wed, 15 Feb 2017 17:54:08 -0800 Message-Id: <20170216015408.12933-1-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170215_175433_615030_3B459E09 X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , 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 If a page is marked read only we should print out that fact, instead of printing out that there was a page fault. Right now we get a cryptic error message that something went wrong with an unhandled fault, but we don't evaluate the esr to figure out that it was a read/write permission fault. Instead of seeing: Unable to handle kernel paging request at virtual address ffff000008e460d8 pgd = ffff800003504000 [ffff000008e460d8] *pgd=0000000083473003, *pud=0000000083503003, *pmd=0000000000000000 Internal error: Oops: 9600004f [#1] PREEMPT SMP we'll see: Internal error: Attempting to write read-only memory: 9600004f [#1] PREEMPT SMP Cc: Laura Abbott Cc: Mark Rutland Signed-off-by: Stephen Boyd --- arch/arm64/mm/fault.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 156169c6981b..752507fa80ec 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -331,6 +331,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, if (!search_exception_tables(regs->pc)) die("Accessing user space memory outside uaccess.h routines", regs, esr); + } else if (is_permission_fault(esr, regs)) { + if (esr & ESR_ELx_WNR) + die("Attempting to write read-only memory", regs, esr); + else + die("Attempting to read unreadable memory", regs, esr); } /*