Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1798448pxa; Thu, 6 Aug 2020 16:39:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/WeN3GWjvBkDIgvZ+DBWCiJBrL8Yz+TOvUUc3dO8cagUjul6j4btnwsOEzmfDYDtuZEzt X-Received: by 2002:a17:906:6546:: with SMTP id u6mr6536965ejn.159.1596757193896; Thu, 06 Aug 2020 16:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596757193; cv=none; d=google.com; s=arc-20160816; b=p/mHa0rbeQ44cMUNDOeF3HpiH627RHldUQICVIDVchAzTeRlR3Azp5h1wcOh0LBqks qI6A0IJKyqMelCTRD4ankIaIHIfExCYkK5+uFu8OLiyu9F/FURouxiT+2MNFVWRlXQTh pdBFA3mITBExh6sotpsR7nBIAV8Wn3a+SE0O2kBLCy/pzAZMXbBrlTcWYeNqfB0P+E1R jai+LUWYcGEjGtbuIIHkvTQaYe/D5VHToSFzLmB0pZ5N5vPwq1FgxNyYQbrfEF23SUo7 7AP0ZiVHuWdQPnaE4l8yKuOyzZvAPl3g1e4i2yQmReCLx6LKcc+ljcBtBDhKjGTvZSYw nPLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=euZjanT6kjbBMt9mOI93vtI7+GhGL3QWOcr5yXnKhJE=; b=Hmy/AMTZ7Xmn8mrIldCv+P6PppCp8hjaY2h/AnM+ohzOfCffdzaPZJg3koHhObt9lY DXAd7Jyy7WKkjx1DLydQvCudL+0TACJ/ygMklGQVMWyvFtauEK3noQt91eaF72wZqZJZ /pN+6Lg+UHmcSuyZMLT9BqE2YYURqbx9ntynPlMzAsUh1k1Dw3VoHxVoOlyt5MDjOavj HIAdrYAtmU/peeAOpL5ROZFFPGpdmuu9oFbIaoCXlBJZKzrbwrAuDH3u4ADDqZCROevh hIcM4VhexUnczmyEbGT67f1JwpSD+G7qBRSaEtSCx/VIQZeVi+RXRV79347aq3uZfWMM YPvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=kf8WYWyI; dkim=neutral (no key) header.i=@vger.kernel.org; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si3878763edu.590.2020.08.06.16.39.31; Thu, 06 Aug 2020 16:39:53 -0700 (PDT) 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=fail header.i=@linutronix.de header.s=2020 header.b=kf8WYWyI; dkim=neutral (no key) header.i=@vger.kernel.org; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbgHFXiy (ORCPT + 99 others); Thu, 6 Aug 2020 19:38:54 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60886 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726394AbgHFXis (ORCPT ); Thu, 6 Aug 2020 19:38:48 -0400 Date: Thu, 06 Aug 2020 23:38:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1596757125; h=from:from:sender:sender:reply-to: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=euZjanT6kjbBMt9mOI93vtI7+GhGL3QWOcr5yXnKhJE=; b=kf8WYWyISqdKVTZ2qXYD+2hk0lxkEAf+0v7bHBofb9N6u/IN9As1dksbij1WiFHTuMHx0i JnG6omaFV+bWcpepWA+dbQKGxAWn5kWosViZh5T1vxP9h0mmVrlS9ORuGqW4DzEiY1lpUW S0XVHhmES4n7JyBVBjTApCeB3ZFzvMlF3TvmveX5Pf5Nza81UBsd8jOcUypwKTUnJxzpp3 A3qasIokbrzDO4+LdB3acJof5yrhxDHORRJygcXO4/IhuFWrj6egSOCO0QWjH6FZkmW7Z4 SeKcZQcpJbHXkeSIyFufSm2h/a+fisK50ku/K/F5nk6mzKDb478nR8SR8xbzCw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1596757125; h=from:from:sender:sender:reply-to: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=euZjanT6kjbBMt9mOI93vtI7+GhGL3QWOcr5yXnKhJE=; b=KquSmEdCMCevjaYuCZf7g405FtdyyEiKXlwb78NUmQVxW/tl7EznntXVr7GE3yVGKEIOjE ZD9n7vsmuZxzyeDw== From: "tip-bot2 for Lianbo Jiang" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] kexec_file: Correctly output debugging information for the PT_LOAD ELF header Cc: Lianbo Jiang , Ingo Molnar , Dave Young , x86 , LKML In-Reply-To: <20200804044933.1973-4-lijiang@redhat.com> References: <20200804044933.1973-4-lijiang@redhat.com> MIME-Version: 1.0 Message-ID: <159675712489.3192.10936858740810441552.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 475f63ae63b5102ae6423d1712333929d04d6ecc Gitweb: https://git.kernel.org/tip/475f63ae63b5102ae6423d1712333929d04d6ecc Author: Lianbo Jiang AuthorDate: Tue, 04 Aug 2020 12:49:33 +08:00 Committer: Ingo Molnar CommitterDate: Fri, 07 Aug 2020 01:32:00 +02:00 kexec_file: Correctly output debugging information for the PT_LOAD ELF header Currently, when we enable the debugging switch to debug kexec_file, we always get the following incorrect results: kexec_file: Crash PT_LOAD elf header. phdr=00000000c988639b vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=51 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=000000003cca69a0 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=52 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000c584cb9f vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=53 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000cf85d57f vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=54 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000a4a8f847 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=55 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000272ec49f vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=56 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000ea0b65de vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=57 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=000000001f5e490c vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=58 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000dfe4109e vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=59 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000480ed2b6 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=60 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=0000000080b65151 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=61 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=0000000024e31c5e vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=62 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000332e0385 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=63 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=000000002754d5da vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=64 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=00000000783320dd vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=65 p_offset=0x0 kexec_file: Crash PT_LOAD elf header. phdr=0000000076fe5b64 vaddr=0x0, paddr=0x0, sz=0x0 e_phnum=66 p_offset=0x0 The reason is that kernel always prints the values of the next PT_LOAD instead of the current PT_LOAD. Change it to ensure that we can get the correct debugging information. [ mingo: Amended changelog, capitalized "ELF". ] Signed-off-by: Lianbo Jiang Signed-off-by: Ingo Molnar Acked-by: Dave Young Link: https://lore.kernel.org/r/20200804044933.1973-4-lijiang@redhat.com --- kernel/kexec_file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 97fa682..3f7867c 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1246,7 +1246,7 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map, unsigned long long notes_addr; unsigned long mstart, mend; - /* extra phdr for vmcoreinfo elf note */ + /* extra phdr for vmcoreinfo ELF note */ nr_phdr = nr_cpus + 1; nr_phdr += mem->nr_ranges; @@ -1254,7 +1254,7 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map, * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). * I think this is required by tools like gdb. So same physical - * memory will be mapped in two elf headers. One will contain kernel + * memory will be mapped in two ELF headers. One will contain kernel * text virtual addresses and other will have __va(physical) addresses. */ @@ -1323,10 +1323,10 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map, phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; phdr->p_align = 0; ehdr->e_phnum++; - phdr++; - 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", + 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", phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, ehdr->e_phnum, phdr->p_offset); + phdr++; } *addr = buf;