From patchwork Mon Mar 1 16:15:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 388747 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3677202jap; Mon, 1 Mar 2021 12:39:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJymHF9euS9fhBtAKigM52ZiyIVMUgcxevJtFfCaukTveRlQUudsBgpffDt2je0J6dpuJCDt X-Received: by 2002:a50:fe08:: with SMTP id f8mr15449628edt.217.1614631195041; Mon, 01 Mar 2021 12:39:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614631195; cv=none; d=google.com; s=arc-20160816; b=Aj9aTl62CvRaW+adxl2f01YPJgGDMNudao5vIYVFAOYvtzqu8DOX63lHejbbB1MZDw 8JpReYsPKfigD0I89VuANGdr8G1OEMXCW6wtQJ4ibbfHfi+l7OAkU9haRPN/1QFbuGRl 0jQGyNuB5C6NdIOcj9HglkZClwVCmR5BDdkC5KhXMHXx+FON0Nm1JpyDJ+56yYX4DdJj wZhH/RRh8xRqmtT0XZ2h9Z2XQu6eGvYOCC5M2i0U40Mg+MKS4cSkUL1ChwQ/V+5bzjGT eJvTpxYPAOnfXbwqRPhlRi7+fk2c+Ev73VO/tZa+VOZo7/XLYfh60+IyyzQ6pJBcLCfP BFfQ== 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=FUejv/o0rPoZ1UsZitT2QmhHFW5IdMJrqQ5MAF2+N14=; b=nm1eXSFzA+/nGZSD6zBN02gZVLtzs7yEhfxEV8zhooMWZl0Qu9crlVQWxymuZ4e8h+ FomvNtH20nft5OlFF9DZ4k4lgZsJnBnrWVX2HQhy3kBQGFQwg/X0HxGah/n9x32IFenu WfNLgAuKsjYFYvcZVUYRvSVLKAnHmhDeFxHoqgOfZoq/zttqSRQrQy+bxJoMDhbhio0T q7CCQRRROcF2tcrkRJ+e/xa/g5J4TBCgFPslMpl33/fcqJy78cFD8Rk90qap7xXlaa1C fH72mWO95ndoOpo7fj3kVANZ229h4JlttxkddeU81B8e7GZE9S6L9c1IR43iyao1smZk leew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aqbFMUey; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 c10si2534507edv.12.2021.03.01.12.39.54; Mon, 01 Mar 2021 12:39:55 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=aqbFMUey; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S243623AbhCAUij (ORCPT + 13 others); Mon, 1 Mar 2021 15:38:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:51358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242190AbhCAUbx (ORCPT ); Mon, 1 Mar 2021 15:31:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CFFB264EFC; Mon, 1 Mar 2021 18:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614622129; bh=XzzrrzqM/QAmJDO9/h9kFE/WyVMMOFQjF28RpQ7x6YE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aqbFMUeybX/3q+ml/3u+jYDyTTdJwxwueYdu70Z30tpMiEsSUCNIImj7PdOp79Uiv zTEir/xXVqOdDwMBiC7ylqX4NCeRsdwA2OaVzT+oLl7zsFkhfds4mgQP/rvYRTcJrL 56AXEnkV0T/Lncu9jNFbZwMgy8e/e9N/XCKud05o= 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.11 768/775] kgdb: fix to kill breakpoints on initmem after boot Date: Mon, 1 Mar 2021 17:15:36 +0100 Message-Id: <20210301161239.264500655@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161201.679371205@linuxfoundation.org> References: <20210301161201.679371205@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -1423,6 +1423,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) {