Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3871623pxb; Tue, 2 Mar 2021 00:12:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjKHguKxThY1gNKtjEi2tvKel3ndCC9ih+B8xukFF/HLsqIyIcEQIqJRaMlJB8wyEBWPfG X-Received: by 2002:a17:906:4d96:: with SMTP id s22mr13572240eju.189.1614672745846; Tue, 02 Mar 2021 00:12:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614672745; cv=none; d=google.com; s=arc-20160816; b=hu5Tw834lnZu7PWkVIeyrLpXR0dmL2gX7eVEmNMLhc60CI++16OUrPSn9HgmW5Pi4J aWeSjBTGIvdDZ2hQqz/4hznCEolRMG9ZJhFThYcIaOdaXlDw16Z6dFuWVOHOGOZKplcX TbuHG77nLPY6ShZK/Ga3xklbXLFALpQzxqnbtnQmbeN+7uMZGrXkzEtkKkO1dVjD+1JO 44BR98ABfwqfOdhHlIvc0l8VyBgg7md5BI2dpETWR6npJnCix6C8Jso94i2mragqOwc1 wxncNrtwpuGre/BoaVZ5DOtBKj/VYgv/DIrwJLlfma8k4Vt4Ud4v1qk6aNnxWEVe5nZu k8MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z9L+GvQiwDWzxZN68R27CS2Rqx0hooIjfBhfJITLiHw=; b=beT53ywyVeOwo7ug1LY6tUQqZHTKV1I7XIYNVD2e8aQel9IkCQah8U3KQJ2ckyDDuq PllGQDK74HBXpW4Dr2XP8lQqv8i654zWAc8Iqq7M+7OVnt5G2/HH4Pjw3GW3sw1ZmAvf K/Zu7uJRP6YlGIU8ApXoHAant60Bkni8J7ZldV+CcqlJJyZzCtqtD/gXYCt3PsFCh57/ PpNFvWZCO+QT5OkPHABfa2jOvX3gCPQmTtcO9OhLd9sh73Yk5eNnESpoxGP7/+YYN7GX TwexMfVqm+iYZL+LHN9iUnTDQ0vS4IwAjo/2kAOnBhO9l/rDvjRDhkIBHAZFx64Ukvj1 E9iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gfO8vzg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si6942108edy.508.2021.03.02.00.12.01; Tue, 02 Mar 2021 00:12:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gfO8vzg3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348557AbhCBBDZ (ORCPT + 99 others); Mon, 1 Mar 2021 20:03:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:58012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240534AbhCASxx (ORCPT ); Mon, 1 Mar 2021 13:53:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 94A84652A9; Mon, 1 Mar 2021 17:33:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614620020; bh=rVirLZ6Q6Gw2u0mCRf+mUOcCzhIT6+EVNhEEYFkWRxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gfO8vzg3XveCU2wbrhk21RM7P7S3QmG0NeBWYENLXQkZdqe7zP3fGLPPfhf7PMiVi eqKHVDNIvYW1PzupNsJUT8Yx8dSNFmrhswlcP0N6TnjpOnbvHAWpnhYgv/4sZQZUyM chmZWUufArCZIHX8kTP/TVdKcguy5MFM30wGQiPI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , Doug Anderson , Daniel Thompson , Masami Hiramatsu , "Steven Rostedt (VMware)" , Jason Wessel , Peter Zijlstra , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 656/663] kgdb: fix to kill breakpoints on initmem after boot Date: Mon, 1 Mar 2021 17:15:04 +0100 Message-Id: <20210301161214.311877714@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sumit Garg commit d54ce6158e354f5358a547b96299ecd7f3725393 upstream. Currently breakpoints in kernel .init.text section are not handled correctly while allowing to remove them even after corresponding pages have been freed. Fix it via killing .init.text section breakpoints just prior to initmem pages being freed. Doug: "HW breakpoints aren't handled by this patch but it's probably not such a big deal". Link: https://lkml.kernel.org/r/20210224081652.587785-1-sumit.garg@linaro.org Signed-off-by: Sumit Garg Suggested-by: Doug Anderson Acked-by: Doug Anderson Acked-by: Daniel Thompson Tested-by: Daniel Thompson Cc: Masami Hiramatsu Cc: Steven Rostedt (VMware) Cc: Jason Wessel Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- include/linux/kgdb.h | 2 ++ init/main.c | 1 + kernel/debug/debug_core.c | 11 +++++++++++ 3 files changed, 14 insertions(+) --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -360,9 +360,11 @@ extern atomic_t kgdb_active; extern bool dbg_is_early; extern void __init dbg_late_init(void); extern void kgdb_panic(const char *msg); +extern void kgdb_free_init_mem(void); #else /* ! CONFIG_KGDB */ #define in_dbg_master() (0) #define dbg_late_init() static inline void kgdb_panic(const char *msg) {} +static inline void kgdb_free_init_mem(void) { } #endif /* ! CONFIG_KGDB */ #endif /* _KGDB_H_ */ --- a/init/main.c +++ b/init/main.c @@ -1417,6 +1417,7 @@ static int __ref kernel_init(void *unuse async_synchronize_full(); kprobe_free_init_mem(); ftrace_free_init_mem(); + kgdb_free_init_mem(); free_initmem(); mark_readonly(); --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -456,6 +456,17 @@ setundefined: return 0; } +void kgdb_free_init_mem(void) +{ + int i; + + /* Clear init memory breakpoints. */ + for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) { + if (init_section_contains((void *)kgdb_break[i].bpt_addr, 0)) + kgdb_break[i].state = BP_UNDEFINED; + } +} + #ifdef CONFIG_KGDB_KDB void kdb_dump_stack_on_cpu(int cpu) {