From patchwork Wed Sep 21 07:19:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 76665 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1898591qgf; Wed, 21 Sep 2016 00:17:21 -0700 (PDT) X-Received: by 10.66.155.7 with SMTP id vs7mr61934171pab.154.1474442241453; Wed, 21 Sep 2016 00:17:21 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id l184si74457985pfc.33.2016.09.21.00.17.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Sep 2016 00:17:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; 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 linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bmblH-0004Gf-Sd; Wed, 21 Sep 2016 07:16:07 +0000 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bmbiq-0000eY-HM for linux-arm-kernel@lists.infradead.org; Wed, 21 Sep 2016 07:13:50 +0000 Received: by mail-pf0-x22e.google.com with SMTP id q2so16161894pfj.3 for ; Wed, 21 Sep 2016 00:13:16 -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=b1T4BlXWPwvG6gmxnr1lT4KTU+z8OJ1d3llhWKscIrM=; b=a2PssuuNk1TVjfVsaB+eUb4TVqZauT0vdpMp+pOAub1lFLX5Q6yidhAZ8INfUPpcAV Lw0iS+mQhm1rdfM1peu7klTENlmu01Y2wfwKt7UXm+1HOE7Ax85+UhjitJOU67VvLvhl UQzTBIVAscR+/QwgEaxFquJHqviVXe+Rm+jB0= 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=b1T4BlXWPwvG6gmxnr1lT4KTU+z8OJ1d3llhWKscIrM=; b=M9rr/0srsWG542G+JGq8a9xEmlJih24lbHIl8KPL90IcrgYfhuPnQgZ0Fr9L+6e9CH FZw1CsY2nQgojaq55LM0xp12JVAHPXIjxdZZrqcX3aqkg4aKG3OVlu/8ZkdsBjHaRhTJ YCKRlPPQ/MwycDgO96nC6zqNJukJ9RVEJYZqD9b1jut8cM3EzwwyoSbfrhcUH111/opP O4/ok3toVNyA8W6bcjzN/a9fIadM9kEIzfT/6AiM6gr0nLxKfgr/jdpD68n+O7UaBPP6 5bNoaAghZmyQCtdUG6qPLvfn3sx8eTFYyeKo78nMlHSa2yJ3fUx/UWPN5RtNxSPGbUiC h39w== X-Gm-Message-State: AE9vXwN6W+5CtoyyGKThk888uXCqDJ2hhty2sjWymNIuNyvleh3hF9DY7bpct9ds23Mq5wbc X-Received: by 10.98.206.139 with SMTP id y133mr62620143pfg.7.1474441995241; Wed, 21 Sep 2016 00:13:15 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id x9sm83785026pfd.70.2016.09.21.00.13.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Sep 2016 00:13:14 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, jason.wessel@windriver.com Subject: [PATCH v2] arm64: kgdb: handle read-only text / modules Date: Wed, 21 Sep 2016 16:19:55 +0900 Message-Id: <20160921071955.21792-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.10.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160921_001337_450147_6332BE43 X-CRM114-Status: GOOD ( 11.69 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c00:0:0:0:22e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: mark.rutland@arm.com, kgdb-bugreport@lists.sourceforge.net, stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, AKASHI Takahiro MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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 Cc: Catalin Marinas Cc: Will Deacon Cc: Jason Wessel Cc: # 3.18-3.19: 2f896d5: arm64: use fixmap 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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); +}