From patchwork Tue Nov 14 15:32:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 16571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2005029rwb; Tue, 14 Nov 2023 07:34:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzzd5MnLjpUlEgLvbG9OG87o+5LAOZHQa3afYGyKgYbJY+KR4NFf83W2bNFv+G2bSa0Gcx X-Received: by 2002:a05:6a20:1584:b0:181:9518:5aae with SMTP id h4-20020a056a20158400b0018195185aaemr8899441pzj.10.1699976081358; Tue, 14 Nov 2023 07:34:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699976081; cv=none; d=google.com; s=arc-20160816; b=LzP9lCoc9fDKryNDfEfGaRUzp3cVRDK/Vh+S4LQ2vj9IJ8y6jUMoF0m8NqLHZqooyE QpPtjVdDP7ZWRnI4kNOKpLfIfd74kyVb8JGW3MTb43wj6in96ZdzaOh7cBFnxh4iyzfq JBuuZEkDhl94WHYtaDEiMckc3X3o5rwK4xf0FSIEmcvJ+4fF4KeXEkyKFkfCb2V+eKxL ARWXvzh56oXcRXaCnhkScEx8Autm8VHzZ2VoHQnSDD/ADw4MWZMm6fgezPxoRyra49an 6JFYSHrY8iuzKtx4fHGSIMmeow77Qezc3emXAd/Cw3RlMqMIy+igTUBft/gyD7z+6/bP 0ulg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/+dElhLP1quyzdQBmNveEGvmbZDs+wXRqJTs6dmoqmk=; fh=Dzl3/7KOWujfoM5E1QGa6vmlFfKO2meWm3ktMyZ/hPo=; b=DyltOsR6FqDzRS/TUOcu/GPKfYQTkvAlAfQLuKu5Qy+030V2Tpg5mB7HSPoPQSEzJi 3N+fOwd7pCQcDEGiKcOjx5Zt/iz2p2FBXZyF7BxViKni0s+6X+niPtXHPj3lDR8Qw0Gs dE5GlyQyaHUhs6BFWue61iUvW0AcxfBuHPd4DobCnAEShBgB4j0G3suvsoZbMUtH7XaB 6/5Z32Jmt0+bZFJ0n59RjWA28iCySl0VQ8XDHKnJV7oFV+nVdkq1I3bVnh2UJtwqyKQw q4ZOCF0h7gSZ+H6TMxAUzGSJffM3+sM0Ad5A4NmJj5pq1Utz7tQaw57+aTeuquC2wjdZ 88YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fGJo1gVL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id b24-20020a6567d8000000b005b92d40e115si8350196pgs.698.2023.11.14.07.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 07:34:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fGJo1gVL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 78F67802555E; Tue, 14 Nov 2023 07:34:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233689AbjKNPdc (ORCPT + 29 others); Tue, 14 Nov 2023 10:33:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233670AbjKNPda (ORCPT ); Tue, 14 Nov 2023 10:33:30 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86B68125 for ; Tue, 14 Nov 2023 07:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699976005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/+dElhLP1quyzdQBmNveEGvmbZDs+wXRqJTs6dmoqmk=; b=fGJo1gVLU6TfcouM7CLVUj+a7O2Jb1EBgzX3nCKhTgSajWgDRx2/KGciX6stJ+wqdtl21Y 9Cpq6EngAPBOXGSNomvR13N0K0cPpd6DbASfaGIjj22uJQhV8jBgVYOYW2jP+jlJ4OlyFG oWhMmeax/1PTBlturri54ylqXeTObvE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-N9Dy5BYSNKe1LYvnmcJoug-1; Tue, 14 Nov 2023 10:33:22 -0500 X-MC-Unique: N9Dy5BYSNKe1LYvnmcJoug-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB809103B81C; Tue, 14 Nov 2023 15:32:59 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id A09871C060AE; Tue, 14 Nov 2023 15:32:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-parisc@vger.kernel.org, Baoquan He Subject: [PATCH 0/7] kexec_file: print out debugging message if required Date: Tue, 14 Nov 2023 23:32:46 +0800 Message-ID: <20231114153253.241262-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 14 Nov 2023 07:34:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782554064123189642 X-GMAIL-MSGID: 1782554119469080871 Currently, specifying '-d' will print a lot of debugging information about kexec/kdump loading with kexec_load interface. However, kexec_file_load prints nothing even though '-d' is specified. It's very inconvenient to debug or analyze the kexec/kdump loading when something wrong happened with kexec/kdump itself or develper want to check the kexec/kdump loading. In this patchset, a kexec_file flag is KEXEC_FILE_DEBUG added and checked in code. If it's passed in, debugging message of kexec_file code will be printed out and can be seen from console and dmesg. Otherwise, the debugging message is printed via pr_debug(). Note: ===== 1) The code in kexec-tools utility also need be changed to support passing KEXEC_FILE_DEBUG to kernel when 'kexec -s -d' is specified. The patch link is here: ========= [PATCH] kexec_file: add kexec_file flag to support debug printing http://lists.infradead.org/pipermail/kexec/2023-November/028505.html 2) s390 also has kexec_file code, while I am not sure what debugging information is necessary. So leave it to s390 dev to add if they think it's needed. Test: ====== I did testing on x86_64 and arm64. On x86_64, the printed messages look like below: -------------------------------------------------------------- kexec measurement buffer for the loaded kernel at 0x207fffe000. Loaded purgatory at 0x207fff9000 Loaded boot_param, command line and misc at 0x207fff3000 bufsz=0x1180 memsz=0x1180 Loaded 64bit kernel at 0x207c000000 bufsz=0xc88200 memsz=0x3c4a000 Loaded initrd at 0x2079e79000 bufsz=0x2186280 memsz=0x2186280 Final command line is: root=/dev/mapper/fedora_intel--knightslanding--lb--02-root ro rd.lvm.lv=fedora_intel-knightslanding-lb-02/root console=ttyS0,115200N81 crashkernel=256M E820 memmap: 0000000000000000-000000000009a3ff (1) 000000000009a400-000000000009ffff (2) 00000000000e0000-00000000000fffff (2) 0000000000100000-000000006ff83fff (1) 000000006ff84000-000000007ac50fff (2) ...... 000000207fff6150-000000207fff615f (128) 000000207fff6160-000000207fff714f (1) 000000207fff7150-000000207fff715f (128) 000000207fff7160-000000207fff814f (1) 000000207fff8150-000000207fff815f (128) 000000207fff8160-000000207fffffff (1) nr_segments = 5 segment[0]: buf=0x000000004e5ece74 bufsz=0x211 mem=0x207fffe000 memsz=0x1000 segment[1]: buf=0x000000009e871498 bufsz=0x4000 mem=0x207fff9000 memsz=0x5000 segment[2]: buf=0x00000000d879f1fe bufsz=0x1180 mem=0x207fff3000 memsz=0x2000 segment[3]: buf=0x000000001101cd86 bufsz=0xc88200 mem=0x207c000000 memsz=0x3c4a000 segment[4]: buf=0x00000000c6e38ac7 bufsz=0x2186280 mem=0x2079e79000 memsz=0x2187000 kexec_file_load: type:0, start:0x207fff91a0 head:0x109e004002 flags:0x8 --------------------------------------------------------------------------- Baoquan He (7): kexec_file: add kexec_file flag to control debug printing kexec_file: print out debugging message if required kexec_file, x86: print out debugging message if required kexec_file, arm64: print out debugging message if required kexec_file, ricv: print out debugging message if required kexec_file, power: print out debugging message if required kexec_file, parisc: print out debugging message if required arch/arm64/kernel/kexec_image.c | 2 +- arch/arm64/kernel/machine_kexec.c | 24 ++++++------------------ arch/arm64/kernel/machine_kexec_file.c | 6 +++--- arch/parisc/kernel/kexec_file.c | 6 +++--- arch/powerpc/kexec/elf_64.c | 8 ++++---- arch/powerpc/kexec/file_load_64.c | 14 +++++++------- arch/riscv/kernel/elf_kexec.c | 9 +++++---- arch/riscv/kernel/machine_kexec.c | 26 -------------------------- arch/x86/kernel/crash.c | 2 +- arch/x86/kernel/kexec-bzimage64.c | 23 ++++++++++++++--------- include/linux/kexec.h | 14 +++++++++++++- include/uapi/linux/kexec.h | 1 + kernel/crash_core.c | 3 ++- kernel/kexec_file.c | 12 +++++++++++- security/integrity/ima/ima_kexec.c | 2 +- 15 files changed, 72 insertions(+), 80 deletions(-)