Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp787830rdh; Thu, 23 Nov 2023 19:37:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IG29Z+KnSC0LdVsaz5XrHiYkSRBYi2iE5QAg3RQ1dJshaLoxZAzZSgySb+YOW0y9qkLvP/U X-Received: by 2002:a05:6a00:1790:b0:6cb:8b26:9793 with SMTP id s16-20020a056a00179000b006cb8b269793mr2009840pfg.24.1700797069910; Thu, 23 Nov 2023 19:37:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700797069; cv=none; d=google.com; s=arc-20160816; b=WcDHnJ1L6ZiE4koICK3mOR5Yje6KqGXSUbVuGNN4Waadh+NNE/SsFNYIL9oEUtq5gT RqAHdBe2ytBRRhduM0/uk5PbY6v4jYVd6uu0VUXjNIt+hJp02Rs5HoTnRxq8/+El2LoS gEAbCjJkUNCnwiSCI34Yb/zB+ATwkAG5tAM6/740MBrnVSVEUEX+RCKl49et4BwCa+Ov S6BgTmD6onnWHI2HYNAr1hoMmUBlTIpNLrIYRoHKFEM1IpyA40SWZno9JgUUW/x9MNx8 L5CPWy5ln+hB4zbmC8p0R4uXeaeVvM+RRkFw3Cn4yytA9PanYfvYADMOm/pITJ84DAgA PKQw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ypSBKOvs5nashSP3TmwrugZ2AS56bQmFrg9V7LWlVpY=; fh=f9/4L5WTkyMs0HwKLVSZtc0UzQZDbbmz4se+5IAJiu4=; b=K7QSVnbWcVwc8GxHREBfXsZ7Me7ge3MOoLI5/WVrp28XXVxYygocDM9/POUKelJmLs cTQT0xRz/vETPtEKo9dbbHqCq26tjH98iTr8XI9MbqYz5EqmDr0DbVTFIB6vjMCmDF7q Zlb8ToGHwMJiivBobzHHyUOV2ajfUjIf3ytLaf3bQBLCoTcjr2VtZwLDgEiDTLyEQKFL MO2kgj7g9XznIEj5yJPRGnPKelFH/AuS9lliQ9Y0DC7TxzuwNynwLicfueIIfkZpdLbI d6ILCPx/OQCzeMEpfrcDTVC0xroPNtjsTr1m0EDm+q/u0dFn3hZS5o5JPj0Vh+H60Sr4 O50A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f3acO70Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id q9-20020a656249000000b005bdbda280c2si2560297pgv.364.2023.11.23.19.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 19:37:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f3acO70Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 9361D829B889; Thu, 23 Nov 2023 19:37:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbjKXDhA (ORCPT + 99 others); Thu, 23 Nov 2023 22:37:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbjKXDg6 (ORCPT ); Thu, 23 Nov 2023 22:36:58 -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 DA4B310DD for ; Thu, 23 Nov 2023 19:37:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700797024; 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: in-reply-to:in-reply-to:references:references; bh=ypSBKOvs5nashSP3TmwrugZ2AS56bQmFrg9V7LWlVpY=; b=f3acO70YNGFyhrx5czPYQ81PZX2fxnsyAfTmQ+xjK2E+GocrOxLZnRDNQsJdQFz6ypzvGL MhdxPyY1C2pFMtyY6auKhD1tSfJ8Xz+Jsm258gKrfWiHnywgVzcuXscDOl8m9FkNP8KAQ2 6a+VeXAxc6RSsHGpu3+G1QHFBkE3z48= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-357-j-to0uXUNdemQMs-yqzn9w-1; Thu, 23 Nov 2023 22:37:00 -0500 X-MC-Unique: j-to0uXUNdemQMs-yqzn9w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 DF59B1C0434A; Fri, 24 Nov 2023 03:36:59 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61AAB492BE7; Fri, 24 Nov 2023 03:36:55 +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, akpm@linux-foundation.org, joe@perches.com, nathan@kernel.org, yujie.liu@intel.com, Baoquan He Subject: [PATCH v2 2/7] kexec_file: print out debugging message if required Date: Fri, 24 Nov 2023 11:36:37 +0800 Message-ID: <20231124033642.520686-3-bhe@redhat.com> In-Reply-To: <20231124033642.520686-1-bhe@redhat.com> References: <20231124033642.520686-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 19:37:46 -0800 (PST) Replace pr_debug() with the newly added kexec_dprintk() in kexec_file loading related codes. And also print out type/start/head of kimage and flags to help debug. Signed-off-by: Baoquan He --- kernel/crash_core.c | 5 ++++- kernel/kexec_file.c | 7 ++++++- security/integrity/ima/ima_kexec.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index efe87d501c8c..1485fd7bb67f 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -551,9 +551,12 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; phdr->p_align = 0; ehdr->e_phnum++; - pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", +#ifdef CONFIG_KEXEC_FILE + kexec_dprintk("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, " + "sz=0x%llx e_phnum=%d p_offset=0x%llx\n", phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, ehdr->e_phnum, phdr->p_offset); +#endif phdr++; } diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 4c35500ae40a..7ae1b0901aa4 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -206,6 +206,8 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, if (ret < 0) return ret; image->kernel_buf_len = ret; + kexec_dprintk("kernel: %p kernel_size: %#lx\n", + image->kernel_buf, image->kernel_buf_len); /* Call arch image probe handlers */ ret = arch_kexec_kernel_image_probe(image, image->kernel_buf, @@ -389,11 +391,12 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd, if (ret) goto out; + kexec_dprintk("nr_segments = %lu\n", image->nr_segments); for (i = 0; i < image->nr_segments; i++) { struct kexec_segment *ksegment; ksegment = &image->segment[i]; - pr_debug("Loading segment %d: buf=0x%p bufsz=0x%zx mem=0x%lx memsz=0x%zx\n", + kexec_dprintk("segment[%d]: buf=0x%p bufsz=0x%zx mem=0x%lx memsz=0x%zx\n", i, ksegment->buf, ksegment->bufsz, ksegment->mem, ksegment->memsz); @@ -408,6 +411,8 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd, if (ret) goto out; + kexec_dprintk("kexec_file_load: type:%u, start:0x%lx head:0x%lx flags:0x%lx\n", + image->type, image->start, image->head, flags); /* * Free up any temporary buffers allocated which are not needed * after image has been loaded diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c index ad133fe120db..e692624bcab3 100644 --- a/security/integrity/ima/ima_kexec.c +++ b/security/integrity/ima/ima_kexec.c @@ -129,7 +129,7 @@ void ima_add_kexec_buffer(struct kimage *image) image->ima_buffer_size = kexec_segment_size; image->ima_buffer = kexec_buffer; - pr_debug("kexec measurement buffer for the loaded kernel at 0x%lx.\n", + kexec_dprintk("kexec measurement buffer for the loaded kernel at 0x%lx.\n", kbuf.mem); } #endif /* IMA_KEXEC */ -- 2.41.0