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=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 9DB32C388F9 for ; Tue, 27 Oct 2020 12:00:01 +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 43D6022263 for ; Tue, 27 Oct 2020 12:00: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="ReCIatmt"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tQGsNr7H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43D6022263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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=UMmgKAVmrdMuQpKchfhjcUJfZ97kcYchNZFbeUkP3x0=; b=ReCIatmtE4vLDNxlKXkJYVLy6 a44sc2Ofl2qUFAjpJmmtayw+bTA7Ot6b6F5nDSngAnk9Jz/gnkYA7VTInqlXt9bLOo4XFWS1UcW9l J1Ytgvfu5/+r+nToceRTpKJXh7deYYG5sgAJgr/P6/o8t9hsSlLpw/xsKtJ5fl4gq/tR8v+RNCMDB qJihSSmLX6N0B0OeLe7hWEofHp+an1SuEqAlwAPLkC9QxzfG7TyKaqLfperwcqFrjmuainqh63kG3 micec4BH8+DPXQgLNzyqAuDu+M7+0LTsLV7e7NvArnN2XgzYeiMWNvPdseGHoHsioOmw6fAiNqrkD OO/FcFk4A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXNdV-0002lB-90; Tue, 27 Oct 2020 11:59:33 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXNdS-0002kQ-Nu for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2020 11:59:31 +0000 Received: by mail-ej1-x641.google.com with SMTP id ce10so1830023ejc.5 for ; Tue, 27 Oct 2020 04:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8vwjI+RLZYpVvDoqxmoo+MI6FY15aH0vH6SgQU+OiN8=; b=tQGsNr7H4ksUxfgBiaXl1CJ2xDh9jyiZHdVMnu/Wj/X9R8qFu3CkraL552i7Mlqpst KMwLQONBIc9roSjG6T0mquqkyrUSkFJ86lEMFv3HIKzSJ4kfCWDf5VAnLve+KmMlX7Z8 iVPkCSxbO18xcCEdImj852F9a7RmZY7ZY0b67gTARflq80VvLDCfLZtf5C4ESz/8pVWt tQr2KK7LE4TUWYUY3TKG04XTQeAb8g9XV3ORge8hi53v/6e8ci7J2W8JkdGCpXcMV5sW HbSj5dE1r0Pvr9ugGsN9HLB5MvRqL995oZm1fDoSd6N1iPb33n+bIwPoZLSnogFPHhN8 zDZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8vwjI+RLZYpVvDoqxmoo+MI6FY15aH0vH6SgQU+OiN8=; b=RrgtCPv3Dbk+BUUjpOJz+eGivWXcpcmVOIjX5m3GTjv0/uVJLVtabsNKZ1/2ccx8i8 VdfXf6PMb1e5zgWfnyjdgrPRxr70yWcC7g5FO9uggXw0TbagwBVGzxgmln4ja0IGTWjj m7wN8u5Sh7BGZ8M4RqszccB6Nj9VxF/xpGCg6VzZr+X/Bq/WiryZGD322QIIokK652Ps 9hUmiND72ZW4ZzpQY4jzt+nCI96cAdQYeHqplA4EQYlZ39jFotnWNsCE+m4BzoKPCL1v KmBpRrZFAoI4KmNMHcBjX6s72EGf1k7BcIeXh9JhGwtVIPkpTXcXskILjqTm1igJh8lX 8BfA== X-Gm-Message-State: AOAM532qqPMPCRdfjOo8dz60VSW3Ebf96LulrECqVXfJXaAqLpumfbbC q0TrCgdKt8bqNayqV1ZPEabBYg== X-Google-Smtp-Source: ABdhPJyLDp05i5RpZT9MREOueCLmWoo0b2wKJPKbPR2m1TWQE3LxSyUGtV8PkFVFZJXaOUW4Spw0TQ== X-Received: by 2002:a17:906:52c6:: with SMTP id w6mr1902113ejn.199.1603799969062; Tue, 27 Oct 2020 04:59:29 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id s25sm870266ejc.29.2020.10.27.04.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 04:59:28 -0700 (PDT) Date: Tue, 27 Oct 2020 12:59:09 +0100 From: Jean-Philippe Brucker To: Masami Hiramatsu Subject: Re: [PATCH] arm64: Fix early single-stepping Message-ID: <20201027115909.GB1514990@myrica> References: <20201026172907.1468294-1-jean-philippe@linaro.org> <20201027191318.aba935f7ccf00af9acd89388@kernel.org> <20201027194258.43b157ac0bbccd918fc8756a@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201027194258.43b157ac0bbccd918fc8756a@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201027_075930_812333_5BE21D1F X-CRM114-Status: GOOD ( 26.04 ) 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, will@kernel.org, dianders@chromium.org, 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+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 27, 2020 at 07:42:58PM +0900, Masami Hiramatsu wrote: > On Tue, 27 Oct 2020 19:13:18 +0900 > Masami Hiramatsu wrote: > > > On Mon, 26 Oct 2020 18:29:09 +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. > > > > > > Fixes: 36dadef23fcc ("kprobes: Init kprobes in early_initcall") > > > Signed-off-by: Jean-Philippe Brucker > > > > Hi Jean, > > > > How have you confirmed this fixes the issue? > > On my environment, this doesn't fix the issue. > > Oops, it was my mistake. I missed to boot up with Xen. (so I find another bug...) > Anyway this works for me too. No worries :) Although now I've been wondering whether it would be better to just disable the OS lock lazily, on the first call to enable_debug_monitors(). It might add a tiny performance penalty but would avoid this problem reappearing if one of the debugger needs to start even earlier in the future. > Reviewed-by: Masami Hiramatsu > Tested-by: Masami Hiramatsu Thanks! Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel