From patchwork Sun Apr 6 22:19:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 27882 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A487F20490 for ; Sun, 6 Apr 2014 22:22:35 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id ur14sf9098794igb.5 for ; Sun, 06 Apr 2014 15:22:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=U0S6KqxpHT2QmVczP72AqBEy+28LJbuvPlH1on5I0e0=; b=ScYJDH8FVPNu5BN+LHDEvMAftyIQC7d1ztewsT9wcW1qInvqlEuDW35nWnt1H0y43h BNxxnVIdq5cBwErx95Tsp/HjUy2rqz1K2HeTVmsoiX5Fksa7PEIM1ziYz05XiF5yJgeE ZP4Y7CLKGLnL52S7H9huTbjDEwvzQf57q3AB0MuS7R1Meai4FXZQpLQVw6R9FL3XKWCN 3ny3/W15+cfXrxT+0/gxIsXhr3NCQN/UCrv+yiQtV25cKbSynUS64Ykg2nBFXREkXV4+ 9VlZ3Q0DBWnhT7aVvwDfyEoTYtwA9PukNTUZbFx5l9+iwovTDDnNCxj1h9DIR0hc7qjF AhIA== X-Gm-Message-State: ALoCoQlQrGPbmcPJc9VIZaYpJWVS+22Nl2LmjqRMZ6Jyq5r6ASG+PnOJCP74ndDkxlix+SoVDhgy X-Received: by 10.50.114.134 with SMTP id jg6mr8486783igb.2.1396822955139; Sun, 06 Apr 2014 15:22:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.136 with SMTP id v8ls1521658qgd.13.gmail; Sun, 06 Apr 2014 15:22:35 -0700 (PDT) X-Received: by 10.220.191.134 with SMTP id dm6mr9647585vcb.16.1396822955055; Sun, 06 Apr 2014 15:22:35 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id tq2si2808019vdc.21.2014.04.06.15.22.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 06 Apr 2014 15:22:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so2939309veb.41 for ; Sun, 06 Apr 2014 15:22:35 -0700 (PDT) X-Received: by 10.58.74.38 with SMTP id q6mr17037695vev.7.1396822954969; Sun, 06 Apr 2014 15:22:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp116561vcv; Sun, 6 Apr 2014 15:22:34 -0700 (PDT) X-Received: by 10.180.83.196 with SMTP id s4mr21566504wiy.24.1396822954081; Sun, 06 Apr 2014 15:22:34 -0700 (PDT) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id sl4si3968820wic.80.2014.04.06.15.22.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Apr 2014 15:22:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWvQT-0007kg-Vh; Sun, 06 Apr 2014 22:20:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWvQH-0008EU-Sl; Sun, 06 Apr 2014 22:20:17 +0000 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21] helo=cam-smtp0.cambridge.arm.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWvPv-0008AU-Dq for linux-arm-kernel@lists.infradead.org; Sun, 06 Apr 2014 22:19:56 +0000 Received: from e102109-lin.cambridge.arm.com (e102109-lin.cambridge.arm.com [10.1.203.182]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s36MJSBK019713; Sun, 6 Apr 2014 23:19:29 +0100 From: Catalin Marinas To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] arm64: Expose ESR_EL1 information to user when SIGSEGV/SIGBUS Date: Sun, 6 Apr 2014 23:19:06 +0100 Message-Id: <1396822746-26241-4-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 1.7.12.3 In-Reply-To: <1396822746-26241-1-git-send-email-catalin.marinas@arm.com> References: <1396822746-26241-1-git-send-email-catalin.marinas@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140406_181955_702085_9849F71E X-CRM114-Status: GOOD ( 10.19 ) X-Spam-Score: -2.9 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [217.140.96.21 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.3 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Peter Maydell X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: catalin.marinas@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This information is useful for instruction emulators to detect read/write and access size without having to decode the faulting instruction. The current patch exports it via sigcontext (struct esr_context) and is only valid for SIGSEGV and SIGBUS. Signed-off-by: Catalin Marinas --- arch/arm64/include/uapi/asm/sigcontext.h | 7 +++++++ arch/arm64/kernel/signal.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/arm64/include/uapi/asm/sigcontext.h b/arch/arm64/include/uapi/asm/sigcontext.h index 690ad51cc901..b72cf405b3fe 100644 --- a/arch/arm64/include/uapi/asm/sigcontext.h +++ b/arch/arm64/include/uapi/asm/sigcontext.h @@ -53,5 +53,12 @@ struct fpsimd_context { __uint128_t vregs[32]; }; +/* ESR_EL1 context */ +#define ESR_MAGIC 0x45535201 + +struct esr_context { + struct _aarch64_ctx head; + u64 esr; +}; #endif /* _UAPI__ASM_SIGCONTEXT_H */ diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 7ff2eee96c6b..dc2ab1b0ac0d 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -194,6 +194,16 @@ static int setup_sigframe(struct rt_sigframe __user *sf, aux += sizeof(*fpsimd_ctx); } + /* fault information, if valid */ + if (current->thread.fault_code) { + struct esr_context *esr_ctx = + container_of(aux, struct esr_context, head); + __put_user_error(ESR_MAGIC, &esr_ctx->head.magic, err); + __put_user_error(sizeof(*esr_ctx), &esr_ctx->head.size, err); + __put_user_error(current->thread.fault_code, &esr_ctx->esr, err); + aux += sizeof(*esr_ctx); + } + /* set the "end" magic */ end = aux; __put_user_error(0, &end->magic, err);