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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 C518AC4363A for ; Mon, 26 Oct 2020 17:40:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 73FBF22242 for ; Mon, 26 Oct 2020 17:40:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0Y2nXCtt"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="lcjnoQH/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73FBF22242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.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=d4okH2UmL/uSi0VaYVsD9zoXFOA9EG9+UH5mXrV5ujU=; b=0Y2nXCttjC1wsdIP/pmc2TbPa Bo7dEWdIHCDEjf7S0Ngbk11c0ti7ObPCitTpPpi3IAyQknSVmaJGo7AuwQVnqFwpZsv/7vqG6d9sS I1VV5MoUkcM8QgKxKPDSVRKXOp7zo/7J58+dimwY6q+PvMejTGP4W5gnsKhBYiu4urlljn64+xh7s CEOeH6odSWtGFsc7CXak968T0+bHxxqjbWbu86VH7fjFY66U93jO//PWxtEdbbuaYDplQnCDrLRPH WOs0PW4HCsj7c4Y6SvTyxYjvZBEt1rc353sIGimCXGvCtgLJdpnNPMpFu37PwkhzdcqVN2nximVCL +AWbA6i+A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX6SD-0004f2-7V; Mon, 26 Oct 2020 17:38:45 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX6SA-0004ee-T0 for linux-arm-kernel@lists.infradead.org; Mon, 26 Oct 2020 17:38:43 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E52322242; Mon, 26 Oct 2020 17:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603733922; bh=fJ3Y4uUrWfPgs2Tv7JuFQDrmgbzaiEsDdQKFAYYFTFc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lcjnoQH/RXOSS2jaL2YySjUaaa+c0MoHL6mQLgjvVkI2e1GxMyf9pdQqniq1KTJ/P NlMu2Qh7GGbHHJlmxvd12WzQ00RbKIpRNJ6C16uQvYnmRUva8ikRHR1vydOQATgAxz EQJBhH8m68fDdLTsFP/I2pJMRLbvnXhJLXSsaUnM= Date: Mon, 26 Oct 2020 17:38:37 +0000 From: Will Deacon To: Jean-Philippe Brucker Subject: Re: [PATCH] arm64: Fix early single-stepping Message-ID: <20201026173837.GB25131@willie-the-truck> References: <20201026172907.1468294-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201026172907.1468294-1-jean-philippe@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_133843_020882_900356F1 X-CRM114-Status: GOOD ( 15.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, dianders@chromium.org, linux-arm-kernel@lists.infradead.org, mhiramat@kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 26, 2020 at 06:29:09PM +0100, Jean-Philippe Brucker wrote: > To use debug features such as single-step, the OS lock must be unlocked > in the debug registers. Currently this is done in postcore_initcall > which is now too late. > > Commit 36dadef23fcc ("kprobes: Init kprobes in early_initcall") enabled > using kprobes from early_initcall, when OS lock is still locked. So when > kprobe attempts to single-step a patched instruction, instead of > trapping, execution continues until it throws an undef exception: > > [ 0.064233] Kprobe smoke test: started > [ 0.151133] ------------[ cut here ]------------ > [ 0.151458] kernel BUG at arch/arm64/kernel/traps.c:406! > [ 0.151812] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP > ... > [ 0.162689] Call trace: > [ 0.163014] do_undefinstr+0x1d4/0x1f4 > [ 0.163336] el1_sync_handler+0xbc/0x140 > [ 0.163839] el1_sync+0x80/0x100 > [ 0.164154] 0xffffffc01001d004 > [ 0.164527] init_kprobes+0x13c/0x154 > [ 0.164968] do_one_initcall+0x54/0x2e0 > [ 0.165322] kernel_init_freeable+0xf4/0x258 > [ 0.165783] kernel_init+0x20/0x12c > [ 0.166117] ret_from_fork+0x10/0x30 > [ 0.166595] Code: 97ffff53 a9425bf5 17ffff9b f9001bf7 (d4210000) > [ 0.167084] ---[ end trace 36778fdf576e9a79 ]--- > > To fix this, unlock the OS lock as early as possible. Do it in > traps_init() for CPU0, since KGDB wants to use single-step from that > point on according to commit b322c65f8ca3 ("arm64: Call > debug_traps_init() from trap_init() to help early kgdb"). > For secondary CPUs, setup the CPU hotplug handler at early_initcall. Hmm, does this mean we end up setting MDSCR_EL1.KDE before we've reset the hardware breakpoint/watchpoint registers? Why do we need kprobes so early? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel