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.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,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 3C390C43381 for ; Fri, 1 Mar 2019 14:08:02 +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 06EC220850 for ; Fri, 1 Mar 2019 14:08:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uhTWoYhf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06EC220850 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=n3Wy4LNbPZmF2TObumGuxmfgzSGHONkUq51deIeEScE=; b=uhTWoYhfbSXzAW BOArd2Lakl4rN9u7rsb9te115DZ3gI+/2zfOP/R65Zhox0ADF3EbjcW13QtN8uaPiir8nNS/VmsAG UZ55kzfpBHXh9UuILG1Xwnt4wc+aoIhr8mHCin0eCdtD304vNHpqrugkvx2juVmzxCED+X5cDp00k D2356OxAa0EuJnYmtQGJVyXpEjQ/fXeM38uCGfE/iUE5+g0B43QslOkV0kPcHBua6gWQvDbC25koW D4FmWR0Z2zqHtpId6bzeg25G/NJbF0KY5ATIg3qlijBeSwEWdBMvv6qZEyZHmzn6VZzTQL2IUTvRd snRR3ClOosowBkU9GTJg==; 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 1gzipR-0000WH-NB; Fri, 01 Mar 2019 14:07:57 +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 1gzipN-0000Vu-CD for linux-arm-kernel@lists.infradead.org; Fri, 01 Mar 2019 14:07:56 +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 85A15165C; Fri, 1 Mar 2019 06:07:52 -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 BC7233F720; Fri, 1 Mar 2019 06:07:51 -0800 (PST) Date: Fri, 1 Mar 2019 14:07:49 +0000 From: Mark Rutland To: Will Deacon Subject: Re: [PATCH 06/10] arm64: debug: Separate debug hooks based on target exception level Message-ID: <20190301140749.GF15517@lakrids.cambridge.arm.com> References: <20190301132809.24653-1-will.deacon@arm.com> <20190301132809.24653-7-will.deacon@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190301132809.24653-7-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_060754_755826_0A170F59 X-CRM114-Status: GOOD ( 17.67 ) 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:05PM +0000, Will Deacon wrote: > Mixing kernel and user debug hooks together is highly error-prone as it > relies on all of the hooks to figure out whether the exception came from > kernel or user, and then to act accordingly. > > Make our debug hook code a little more robust by maintaining separate > hook lists for user and kernel, with separate registration functions > to force callers to be explicit about the exception levels that they > care about. > > Signed-off-by: Will Deacon [...] > struct break_hook { > struct list_head node; > - u32 esr_val; > - u32 esr_mask; > int (*fn)(struct pt_regs *regs, unsigned int esr); > + u16 imm; > }; It's really nice to see the break_hook data reduced down to the BRK immediate! Unfortunately, I don't thnk that's sufficient for KASAN; please see below. [...] > static int call_break_hook(struct pt_regs *regs, unsigned int esr) > { > struct break_hook *hook; > + struct list_head *list; > int (*fn)(struct pt_regs *regs, unsigned int esr) = NULL; > > + list = user_mode(regs) ? &user_break_hook : &kernel_break_hook; > + > rcu_read_lock(); > - list_for_each_entry_rcu(hook, &break_hook, node) > - if ((esr & hook->esr_mask) == hook->esr_val) > + list_for_each_entry_rcu(hook, list, node) > + if ((esr & BRK64_ESR_MASK) == hook->imm) > fn = hook->fn; Could we please fix up the existing coding style bug by placing braces around the loop body? Coding style says we should, since it's more than a single simple statement, and it would better match what we do in call_step_hook(). [...] > -#define KASAN_ESR_VAL (0xf2000000 | KASAN_BRK_IMM) > -#define KASAN_ESR_MASK 0xffffff00 > - > static struct break_hook kasan_break_hook = { > - .esr_val = KASAN_ESR_VAL, > - .esr_mask = KASAN_ESR_MASK, > .fn = kasan_handler, > + .imm = KASAN_BRK_IMM, > }; > #endif > > @@ -1030,7 +1025,7 @@ int __init early_brk64(unsigned long addr, unsigned int esr, > struct pt_regs *regs) > { > #ifdef CONFIG_KASAN_SW_TAGS > - if ((esr & KASAN_ESR_MASK) == KASAN_ESR_VAL) > + if ((esr & BRK64_ESR_MASK) == KASAN_BRK_IMM) According to , KASAN BRKs can use the whole 0x900-0x9ff range of immediates, and these changes mean that we'll only match 0x900. We probably need an imm_mask field on struct break_hook to cater for that. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel