From patchwork Tue Sep 15 16:16:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 53686 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id E494D22DE5 for ; Tue, 15 Sep 2015 16:18:02 +0000 (UTC) Received: by lamp12 with SMTP id p12sf61929059lam.2 for ; Tue, 15 Sep 2015 09:18:01 -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 :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:cc:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=IjzsJafBxH7jjOnYX0B6NxINFfK/XyoYxJawBrs6Kro=; b=JJuNQr5CV/yo2E0veo90fzy3QOzsuGCXNOAvmYp7oSV14/G/rZ3jG7bFdu2DXA4Q9s f7pPibazsQyFEFn2ZsBHAZPuZn+1jhmr6Y36rE0xchiS3X9MX9Mr/L1e50NBKIeqmysX K0A9kbt5yHsYDKnsU0c5NR4zl8+cT3RUOG2Dx93lP6XFBJBBwmsfugEBicrGVDPIqOuw BxJhUR+U2I2WBnyHwkeNQBL4Z5Z0pp8jNyWuWazd8p1RoVOQtINzEKLFNYBOtWFsPIzP m6fwuUMnEot9CWlGfpTcqkowEjeLjpvsA7MWga6vGUZe55U+1FB+dyru4TRa3fGwDBk6 FPIg== X-Gm-Message-State: ALoCoQln8EMZ/WeTjWOzlRVt1B0i8FRug6XUmrV+nSmzU1IDhA4pYuLMFd1clDbHr73HqLI9ygxC X-Received: by 10.194.240.230 with SMTP id wd6mr1183563wjc.0.1442333881869; Tue, 15 Sep 2015 09:18:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.226 with SMTP id f2ls476410laf.46.gmail; Tue, 15 Sep 2015 09:18:01 -0700 (PDT) X-Received: by 10.112.51.142 with SMTP id k14mr21039269lbo.76.1442333881669; Tue, 15 Sep 2015 09:18:01 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id r3si14649379lah.52.2015.09.15.09.18.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 09:18:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lamp12 with SMTP id p12so109920550lam.0 for ; Tue, 15 Sep 2015 09:18:01 -0700 (PDT) X-Received: by 10.152.26.41 with SMTP id i9mr22542622lag.36.1442333881508; Tue, 15 Sep 2015 09:18:01 -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.112.59.35 with SMTP id w3csp1901353lbq; Tue, 15 Sep 2015 09:18:00 -0700 (PDT) X-Received: by 10.60.155.198 with SMTP id vy6mr3859641oeb.27.1442333880322; Tue, 15 Sep 2015 09:18:00 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id y3si10410662oie.0.2015.09.15.09.17.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 09:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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 1ZbsuI-0002sB-Lt; Tue, 15 Sep 2015 16:16:34 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbsuE-0002nq-Kp for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2015 16:16:32 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.139]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id t8FGG8wo005733; Tue, 15 Sep 2015 17:16:08 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 23BD81AE33CB; Tue, 15 Sep 2015 17:16:14 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: hw_breakpoint: use target state to determine ABI behaviour Date: Tue, 15 Sep 2015 17:16:13 +0100 Message-Id: <1442333773-16446-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150915_091631_042143_4FD7CF09 X-CRM114-Status: GOOD ( 13.07 ) X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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: Catalin Marinas , Yao Qi , Will Deacon 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: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mailfrom=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 The arm64 hw_breakpoint interface is slightly less flexible than its 32-bit counterpart, thanks to some changes in the architecture rendering unaligned watchpoint addresses obselete for AArch64. However, in a multi-arch environment (i.e. debugging a 32-bit target with a 64-bit GDB under a 64-bit kernel), we need to provide a feature compatible interface to GDB in order for debugging to function correctly. This patch adds a new helper, is_compat_bp, to our hw_breakpoint implementation which changes the interface behaviour based on the architecture of the debug target as opposed to the debugger itself. This allows debugged to function as expected for multi-arch configurations without relying on deprecated architectural behaviours when debugging native applications. Cc: Yao Qi Cc: Catalin Marinas Signed-off-by: Will Deacon --- arch/arm64/kernel/hw_breakpoint.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index bba85c8f8037..2926c3dd6479 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -163,6 +163,12 @@ enum hw_breakpoint_ops { HW_BREAKPOINT_RESTORE }; +static int is_compat_bp(struct perf_event *bp) +{ + struct task_struct *tsk = bp->hw.target; + return tsk && is_compat_thread(task_thread_info(tsk)); +} + /** * hw_breakpoint_slot_setup - Find and setup a perf slot according to * operations @@ -420,7 +426,7 @@ static int arch_build_bp_info(struct perf_event *bp) * Watchpoints can be of length 1, 2, 4 or 8 bytes. */ if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE) { - if (is_compat_task()) { + if (is_compat_bp(bp)) { if (info->ctrl.len != ARM_BREAKPOINT_LEN_2 && info->ctrl.len != ARM_BREAKPOINT_LEN_4) return -EINVAL; @@ -477,7 +483,7 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp) * AArch32 tasks expect some simple alignment fixups, so emulate * that here. */ - if (is_compat_task()) { + if (is_compat_bp(bp)) { if (info->ctrl.len == ARM_BREAKPOINT_LEN_8) alignment_mask = 0x7; else