From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F11BC43381 for ; Fri, 1 Mar 2019 14:16:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3EA7C2084D for ; Fri, 1 Mar 2019 14:16:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eLR5SckA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3EA7C2084D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DqQNKcd/9dN5IStjfp72ioKU7zcSOLgdvgGtBlkxjbA=; b=eLR5SckA57DBH2 RtdWpRWVj52Eu8n/x4DHt3nQ4BxI955+wKz/IUU8UOGLd3EgI+2IgQWSJ4g2MM7OyNTlv/gBpLKcO ybiRCOtgkGuSUk52tUiiz+KT8IHJ8fO4MyWhLNEsjmdHqniK9Vy0Qz0nxzC4eXsgFWZLJtP0Or0ye IjHrP5R+2MP6P6O4O8YSJC9wohKhkMmUISh2/jwHKfJiDxCEN6808BitPtZnC8xYWzDpq+5Wmmuqi TQd91o+h7cCJKrBG4lyvf/yutEk0FKZ/H7ulZxYfd1q7Q78mtNI2nbgbrIZz6/YyHk+ST9+WJwlBv Q3Iwkz3GEhzV3+6TiQzw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzixd-0005UE-PR; Fri, 01 Mar 2019 14:16:25 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzixa-0005Tj-Fb for linux-arm-kernel@lists.infradead.org; Fri, 01 Mar 2019 14:16:23 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0F1BAA78; Fri, 1 Mar 2019 06:16:22 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 46A713F720; Fri, 1 Mar 2019 06:16:21 -0800 (PST) Date: Fri, 1 Mar 2019 14:16:18 +0000 From: Mark Rutland To: Will Deacon Subject: Re: [PATCH 09/10] arm64: probes: Move magic BRK values into brk-imm.h Message-ID: <20190301141618.GJ15517@lakrids.cambridge.arm.com> References: <20190301132809.24653-1-will.deacon@arm.com> <20190301132809.24653-10-will.deacon@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190301132809.24653-10-will.deacon@arm.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_061622_531543_04D47E96 X-CRM114-Status: GOOD ( 18.57 ) 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: catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 01, 2019 at 01:28:08PM +0000, Will Deacon wrote: > kprobes and uprobes reserve some BRK immediates for installing their > probes. Define these along with the other reservations in brk-imm.h > and rename the ESR definitions to be consistent with the others that we > already have. > > Signed-off-by: Will Deacon Modulo the latent bug with KASAN immediates I mentioned in a prior patch: Reviewed-by: Mark Rutland Mark. > --- > arch/arm64/include/asm/brk-imm.h | 4 ++++ > arch/arm64/include/asm/debug-monitors.h | 7 ++----- > arch/arm64/include/asm/esr.h | 4 +--- > arch/arm64/kernel/debug-monitors.c | 2 +- > arch/arm64/kernel/probes/kprobes.c | 2 +- > arch/arm64/kernel/probes/uprobes.c | 2 +- > arch/arm64/kernel/traps.c | 2 +- > 7 files changed, 11 insertions(+), 12 deletions(-) > > diff --git a/arch/arm64/include/asm/brk-imm.h b/arch/arm64/include/asm/brk-imm.h > index 2945fe6cd863..645ea26cca81 100644 > --- a/arch/arm64/include/asm/brk-imm.h > +++ b/arch/arm64/include/asm/brk-imm.h > @@ -11,6 +11,8 @@ > > /* > * #imm16 values used for BRK instruction generation > + * 0x004: for installing kprobes > + * 0x005: for installing uprobes > * Allowed values for kgdb are 0x400 - 0x7ff > * 0x100: for triggering a fault on purpose (reserved) > * 0x400: for dynamic BRK instruction > @@ -18,6 +20,8 @@ > * 0x800: kernel-mode BUG() and WARN() traps > * 0x9xx: tag-based KASAN trap (allowed values 0x900 - 0x9ff) > */ > +#define KPROBES_BRK_IMM 0x004 > +#define UPROBES_BRK_IMM 0x005 > #define FAULT_BRK_IMM 0x100 > #define KGDB_DYN_DBG_BRK_IMM 0x400 > #define KGDB_COMPILED_DBG_BRK_IMM 0x401 > diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h > index 2b136f0f6a35..5a731757a3c4 100644 > --- a/arch/arm64/include/asm/debug-monitors.h > +++ b/arch/arm64/include/asm/debug-monitors.h > @@ -65,12 +65,9 @@ > #define CACHE_FLUSH_IS_SAFE 1 > > /* kprobes BRK opcodes with ESR encoding */ > -#define BRK64_ESR_MASK 0xFFFF > -#define BRK64_ESR_KPROBES 0x0004 > -#define BRK64_OPCODE_KPROBES (AARCH64_BREAK_MON | (BRK64_ESR_KPROBES << 5)) > +#define BRK64_OPCODE_KPROBES (AARCH64_BREAK_MON | (KPROBES_BRK_IMM << 5)) > /* uprobes BRK opcodes with ESR encoding */ > -#define BRK64_ESR_UPROBES 0x0005 > -#define BRK64_OPCODE_UPROBES (AARCH64_BREAK_MON | (BRK64_ESR_UPROBES << 5)) > +#define BRK64_OPCODE_UPROBES (AARCH64_BREAK_MON | (UPROBES_BRK_IMM << 5)) > > /* AArch32 */ > #define DBG_ESR_EVT_BKPT 0x4 > diff --git a/arch/arm64/include/asm/esr.h b/arch/arm64/include/asm/esr.h > index 52233f00d53d..3541720189c9 100644 > --- a/arch/arm64/include/asm/esr.h > +++ b/arch/arm64/include/asm/esr.h > @@ -156,9 +156,7 @@ > ESR_ELx_WFx_ISS_WFI) > > /* BRK instruction trap from AArch64 state */ > -#define ESR_ELx_VAL_BRK64(imm) \ > - ((ESR_ELx_EC_BRK64 << ESR_ELx_EC_SHIFT) | ESR_ELx_IL | \ > - ((imm) & 0xffff)) > +#define ESR_ELx_BRK64_ISS_COMMENT_MASK 0xffff > > /* ISS field definitions for System instruction traps */ > #define ESR_ELx_SYS64_ISS_RES0_SHIFT 22 > diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c > index d9616c34a270..55d46ed6ccc2 100644 > --- a/arch/arm64/kernel/debug-monitors.c > +++ b/arch/arm64/kernel/debug-monitors.c > @@ -317,7 +317,7 @@ static int call_break_hook(struct pt_regs *regs, unsigned int esr) > > rcu_read_lock(); > list_for_each_entry_rcu(hook, list, node) > - if ((esr & BRK64_ESR_MASK) == hook->imm) > + if ((esr & ESR_ELx_BRK64_ISS_COMMENT_MASK) == hook->imm) > fn = hook->fn; > rcu_read_unlock(); > > diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c > index 30502a3c8cf0..42a30f23b85f 100644 > --- a/arch/arm64/kernel/probes/kprobes.c > +++ b/arch/arm64/kernel/probes/kprobes.c > @@ -475,7 +475,7 @@ kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr) > } > > static struct break_hook kprobes_break_hook = { > - .imm = BRK64_ESR_KPROBES, > + .imm = KPROBES_BRK_IMM, > .fn = kprobe_breakpoint_handler, > }; > > diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c > index f37ab9567676..605945eac1f8 100644 > --- a/arch/arm64/kernel/probes/uprobes.c > +++ b/arch/arm64/kernel/probes/uprobes.c > @@ -191,7 +191,7 @@ static int uprobe_single_step_handler(struct pt_regs *regs, > > /* uprobe breakpoint handler hook */ > static struct break_hook uprobes_break_hook = { > - .imm = BRK64_ESR_UPROBES, > + .imm = UPROBES_BRK_IMM, > .fn = uprobe_breakpoint_handler, > }; > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index 3bcd56dd94fa..387c5e18cc46 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -1019,7 +1019,7 @@ int __init early_brk64(unsigned long addr, unsigned int esr, > struct pt_regs *regs) > { > #ifdef CONFIG_KASAN_SW_TAGS > - if ((esr & BRK64_ESR_MASK) == KASAN_BRK_IMM) > + if ((esr & ESR_ELx_BRK64_ISS_COMMENT_MASK) == KASAN_BRK_IMM) > return kasan_handler(regs, esr) != DBG_HOOK_HANDLED; > #endif > return bug_handler(regs, esr) != DBG_HOOK_HANDLED; > -- > 2.11.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel