From patchwork Fri Sep 23 07:42:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 76831 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp428138qgf; Fri, 23 Sep 2016 00:35:16 -0700 (PDT) X-Received: by 10.98.56.148 with SMTP id f142mr10101705pfa.83.1474616116675; Fri, 23 Sep 2016 00:35:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l67si6576629pfg.84.2016.09.23.00.35.16; Fri, 23 Sep 2016 00:35:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754921AbcIWHfP (ORCPT + 3 others); Fri, 23 Sep 2016 03:35:15 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33476 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993AbcIWHfO (ORCPT ); Fri, 23 Sep 2016 03:35:14 -0400 Received: by mail-pa0-f51.google.com with SMTP id hm5so37723465pac.0 for ; Fri, 23 Sep 2016 00:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=IKe9kWAVnPYO7UE0yIe4mJz0190ylqiE+KXLb/XfKOc=; b=XBfMNUW+l2hi9+Z95CnkQL7zkofJsV0UDp7jeZXG215DPk9yqx/Vb9CFclyeMxNaAu hrdVqwNntkxFRklAwNgoa09hEj65w+WnPx8BJO1vWqYrGosqL1uzS2RGj0iJeyRYvTrf za4l5h6XYi6Q9aSXwIHxWiMaF2MvkoEkvQgNQ= 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=IKe9kWAVnPYO7UE0yIe4mJz0190ylqiE+KXLb/XfKOc=; b=cdqiMySoG7NPQj5F5WM2Cc5o6NVxSBqBoFf3cQ3Fnsl/RKmi8BjfmWNEKbx5MVNvAF 9oHJdxUivfL2o/yNmKVwQcrcIccHUxaUAJl6HFyamWmagfFLTZc88gtnUuBVXt2La//H Z69vDO0oZnxXZJAC/B7hlWWdLPv+QybPjf/MCKt2HOoxytLxKW07IQuJOxjuCbCYTsxO fc4/+qpg+la5TjP9yLwRyvrRRaWA/WhsqGdCBsUG7V8DCovoZ13O8p9u01rJLZHiBNmE xF6BBvfDp5ox7N6dqwalXcIW0N5cnoSOTR/wgPMNjQNFrl2fP7A7p+EG7W4Wkzs2sGnI qcaw== X-Gm-Message-State: AE9vXwPxVQx19HKa5TC2EhbkCFY8Uth8jTvJq/jL63fA1sqEgQKE2B2KwXwF463cBIMBm7T5 X-Received: by 10.66.176.141 with SMTP id ci13mr10223234pac.85.1474616114173; Fri, 23 Sep 2016 00:35:14 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id b188sm6091948pfa.82.2016.09.23.00.35.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Sep 2016 00:35:13 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, jason.wessel@windriver.com Cc: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, stable@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v2.1] arm64: kgdb: handle read-only text / modules Date: Fri, 23 Sep 2016 16:42:08 +0900 Message-Id: <20160923074208.9899-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.10.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Handle read-only cases (CONFIG_DEBUG_RODATA/CONFIG_DEBUG_SET_MODULE_RONX) by using aarch64_insn_write() instead of probe_kernel_write(). See how this works: commit 2f896d586610 ("arm64: use fixmap for text patching") Signed-off-by: AKASHI Takahiro Reviewed-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon Cc: Jason Wessel Cc: # 3.18-3.19: 2f896d5: arm64: use fixmap Cc: # 3.18-3.19: f6242ca: arm64: Fix text Cc: # 4.0- --- arch/arm64/include/asm/debug-monitors.h | 2 -- arch/arm64/kernel/kgdb.c | 36 ++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 14 deletions(-) -- 2.10.0 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h index 4b6b3f7..b71420a 100644 --- a/arch/arm64/include/asm/debug-monitors.h +++ b/arch/arm64/include/asm/debug-monitors.h @@ -61,8 +61,6 @@ #define AARCH64_BREAK_KGDB_DYN_DBG \ (AARCH64_BREAK_MON | (KGDB_DYN_DBG_BRK_IMM << 5)) -#define KGDB_DYN_BRK_INS_BYTE(x) \ - ((AARCH64_BREAK_KGDB_DYN_DBG >> (8 * (x))) & 0xff) #define CACHE_FLUSH_IS_SAFE 1 diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 6732a27..b06a7a2 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -19,6 +19,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -26,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -370,15 +373,24 @@ void kgdb_arch_exit(void) unregister_die_notifier(&kgdb_notifier); } -/* - * ARM instructions are always in LE. - * Break instruction is encoded in LE format - */ -struct kgdb_arch arch_kgdb_ops = { - .gdb_bpt_instr = { - KGDB_DYN_BRK_INS_BYTE(0), - KGDB_DYN_BRK_INS_BYTE(1), - KGDB_DYN_BRK_INS_BYTE(2), - KGDB_DYN_BRK_INS_BYTE(3), - } -}; +struct kgdb_arch arch_kgdb_ops; + +int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) +{ + int err; + + BUILD_BUG_ON(AARCH64_INSN_SIZE != BREAK_INSTR_SIZE); + + err = aarch64_insn_read((void *)bpt->bpt_addr, (u32 *)bpt->saved_instr); + if (err) + return err; + + return aarch64_insn_write((void *)bpt->bpt_addr, + (u32)AARCH64_BREAK_KGDB_DYN_DBG); +} + +int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) +{ + return aarch64_insn_write((void *)bpt->bpt_addr, + *(u32 *)bpt->saved_instr); +}