From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bg1.exmail.qq.com (bg1.exmail.qq.com [114.132.77.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0CC33164B0 for ; Fri, 12 Dec 2025 09:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.132.77.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765533575; cv=none; b=A14O900NY5BASbwWeWW8+Aognvj1hHoKJ8aNW7fIBR/f78ixDFmEa0992w6CQ10HmnG4mbh/e7ZsJQ6WfaZa9y0YMa+U7hW2K7NBzXTdqL3vy2VfySXDKBO4gd7Rf12oi/H/usx7XjwMRSXJedU6slsboKLnMGhR2MSDtEmn6zE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765533575; c=relaxed/simple; bh=ROSrLtE9Y8KSC1PR+QWFXUD/l0o/Cl8jtbd1THLMKio=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P07eUry7BZOV4ne2kOKJfyAiM3HNlOC5BUM1LnKg8nvs4hMaUZkoG4Ja+KUg4kcXU3/ObESYCIZtQSWPLa+zJPoCuTeHFziz8C74JG1Gp3/jmPMaJQFZGTZ4pcZxtJoSw7uomfrjZ/cJr+waBx/AzqrM2CkZffpXzPRzWuvEGFE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=lSIqpiQv; arc=none smtp.client-ip=114.132.77.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="lSIqpiQv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1765533489; bh=hlpIS4p5oycsQ08DmcPjo7M49fd+td9zG0Th5DgBMX8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=lSIqpiQvTvPXBtA/vWLd2ccSX0jzsmI4Sbj9aMl+2wkWFjqspzQuU6ulbSMntuxvw SqpnSC8/5+niEsdqoHmycKBukpvKDSxXCCSVbD2bqk/3qLywCwfSN+SAIc/9aMWFCB y9gURLj6VMMURzLnNQIntMqTKqbAiP/qTPXB03Cw= X-QQ-mid: esmtpsz10t1765533471t617c6373 X-QQ-Originating-IP: NmfuHu3jgBsBZAchuScf++VUIUA1fKMHyTrHgj5sgTk= Received: from localhost.localdomain ( [123.114.60.34]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 Dec 2025 17:57:34 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 1668247607997901334 EX-QQ-RecipientCnt: 8 From: Qiang Ma To: akpm@linux-foundation.org, bhe@redhat.com, catalin.marinas@arm.com, will@kernel.org Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Qiang Ma Subject: [PATCH v1 1/3] kexec: add kexec flag to control debug printing Date: Fri, 12 Dec 2025 17:56:47 +0800 Message-Id: <20251212095649.857796-2-maqianga@uniontech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20251212095649.857796-1-maqianga@uniontech.com> References: <20251212095649.857796-1-maqianga@uniontech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: esmtpsz:uniontech.com:qybglogicsvrsz:qybglogicsvrsz3b-0 X-QQ-XMA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npUQq+yYNwnvqaIU/t5aa6dGl5ak+qOwJIS9Hnmsy1671otjyfAgvjCAlr VzoLE294cfT99OdreZMUKCikssEGPRXYA== X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= X-QQ-RECHKSPAM: 0 The commit cbc2fe9d9cb2 ("kexec_file: add kexec_file flag to control debug printing") added the kexec_file flag to control debug printing. However, for arm64, after commit 6f8c1da071a4 ("kexec_file, arm64: print out debugging message if required"), when using the kexec_load interface, the kexec_image_info function is called to print debug message, but it uses kexec_dprintk, which is only available under kexec_file, then when specifying 'kexec -d', kexec_load interface will print nothing. For riscv, commit eb7622d908a09 ("kexec_file, riscv: print out debugging message if required") remove kexec_image_info(), because the content has been printed out in generic code in kexec_file_load, but not in kexec_load. Therefore, in order to solve the two problems mentioned above, for this patchset, several things need to be done: 1. Enabling kexec_dprintk is available for kexec_load. 2. Add some debugging message of the deleted kexec_image_info to generic code. 3. Remove duplicate debugging prints for arm64 Since kexec_load and kexec_file_load are not triggered simultaneously, we can unify the debug flag of kexec and kexec_file as kexec_dbg_print. In this way, kexec_dprintk is available for kexec_load and kexec_file_load. The following are the key points of the specific changes: 1. rename kexec_file_dbg_print to kexec_dbg_print 2. Add KEXEC_DEBUG 3. Initialize kexec_dbg_print for kexec 4. Set the reset of kexec_dbg_print to kimage_free Signed-off-by: Qiang Ma --- include/linux/kexec.h | 9 +++++---- include/uapi/linux/kexec.h | 1 + kernel/kexec.c | 1 + kernel/kexec_core.c | 4 +++- kernel/kexec_file.c | 4 +--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index ff7e231b0485..23f10aec0b34 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -455,10 +455,11 @@ bool kexec_load_permitted(int kexec_image_type); /* List of defined/legal kexec flags */ #ifndef CONFIG_KEXEC_JUMP -#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR | KEXEC_CRASH_HOTPLUG_SUPPORT) +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR | KEXEC_CRASH_HOTPLUG_SUPPORT | \ + KEXEC_DEBUG) #else #define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR | \ - KEXEC_CRASH_HOTPLUG_SUPPORT) + KEXEC_CRASH_HOTPLUG_SUPPORT | KEXEC_DEBUG) #endif /* List of defined/legal kexec file flags */ @@ -525,10 +526,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } #endif -extern bool kexec_file_dbg_print; +extern bool kexec_dbg_print; #define kexec_dprintk(fmt, arg...) \ - do { if (kexec_file_dbg_print) pr_info(fmt, ##arg); } while (0) + do { if (kexec_dbg_print) pr_info(fmt, ##arg); } while (0) extern void *kimage_map_segment(struct kimage *image, unsigned long addr, unsigned long size); extern void kimage_unmap_segment(void *buffer); diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h index 55749cb0b81d..819c600af125 100644 --- a/include/uapi/linux/kexec.h +++ b/include/uapi/linux/kexec.h @@ -14,6 +14,7 @@ #define KEXEC_PRESERVE_CONTEXT 0x00000002 #define KEXEC_UPDATE_ELFCOREHDR 0x00000004 #define KEXEC_CRASH_HOTPLUG_SUPPORT 0x00000008 +#define KEXEC_DEBUG 0x00000010 #define KEXEC_ARCH_MASK 0xffff0000 /* diff --git a/kernel/kexec.c b/kernel/kexec.c index 9bb1f2b6b268..f6c58c767eb0 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -42,6 +42,7 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry, if (!image) return -ENOMEM; + kexec_dbg_print = !!(flags & KEXEC_DEBUG); image->start = entry; image->nr_segments = nr_segments; memcpy(image->segment, segments, nr_segments * sizeof(*segments)); diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index fa00b239c5d9..7bc1cd4105fc 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -53,7 +53,7 @@ atomic_t __kexec_lock = ATOMIC_INIT(0); /* Flag to indicate we are going to kexec a new kernel */ bool kexec_in_progress = false; -bool kexec_file_dbg_print; +bool kexec_dbg_print; /* * When kexec transitions to the new kernel there is a one-to-one @@ -576,6 +576,8 @@ void kimage_free(struct kimage *image) kimage_entry_t *ptr, entry; kimage_entry_t ind = 0; + kexec_dbg_print = false; + if (!image) return; diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index eb62a9794242..3f1d6c4e8ff2 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -138,8 +138,6 @@ void kimage_file_post_load_cleanup(struct kimage *image) */ kfree(image->image_loader_data); image->image_loader_data = NULL; - - kexec_file_dbg_print = false; } #ifdef CONFIG_KEXEC_SIG @@ -314,7 +312,7 @@ kimage_file_alloc_init(struct kimage **rimage, int kernel_fd, if (!image) return -ENOMEM; - kexec_file_dbg_print = !!(flags & KEXEC_FILE_DEBUG); + kexec_dbg_print = !!(flags & KEXEC_FILE_DEBUG); image->file_mode = 1; #ifdef CONFIG_CRASH_DUMP -- 2.20.1