From patchwork Wed Jul 18 21:37:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 10533335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C915600F4 for ; Wed, 18 Jul 2018 21:38:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B78729C0E for ; Wed, 18 Jul 2018 21:38:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F6E929C11; Wed, 18 Jul 2018 21:38:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B0E5329C0E for ; Wed, 18 Jul 2018 21:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=htwrvQ2ilHzUndoHPl+ITNQ2FyDjdN2Yi6K+Xvy+vek=; b=QVS 6Bprh9cqlt2ZU6HnRCscCIGQDBClFQocuyLUmEHjQ4sl8b2Azpd52m9XOrhNhCv2ZLILGwW/Rvc3F 2UZWVaHAQWUNR7Agn7sHk8PxT/xqNfPHjEj6/4Pb9wM86v48HTzNoJ9Y4vhKELr5fCfvnF3JhSofn k5vXifq4LhZzCy09+75iwIevQrCaclckz2Bfua6ZRHO477C0M3QkEtRiPGUo/IG8zRhJjZroPS7x8 ModkaHbYvdVPNYOcQIhFPuWhApJfmOnQv8IW7nSnZnBNNfr3aBld8VA8hMQrb2DH4ZKpsgHFH0/rw 0jUWXv0u/UleYNZ74GKvpjvPu3s0YZA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffu9J-0006qa-6a; Wed, 18 Jul 2018 21:38:17 +0000 Received: from mail-pg1-f193.google.com ([209.85.215.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffu9F-0006oy-7z for linux-arm-kernel@lists.infradead.org; Wed, 18 Jul 2018 21:38:14 +0000 Received: by mail-pg1-f193.google.com with SMTP id g2-v6so2582059pgs.6 for ; Wed, 18 Jul 2018 14:38:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GBK6tzyDUvOa6mQFoL7jPStc6L4dBwNl9kDKqprSzg4=; b=LCWXSIFaCbxCmbAr7aR+huDOf3N3kIpNiu/m2LbLCzuH7N4997tXCb+qW5tN4hx/+Q 4NXwc2WoNKnExAon1/HhdBXS5cigs4XII741DDnH6gBH9y2h8osfXmfCJSCWIsm9EElG IYbOP8XLyG67XwGhrwclicVXkKCQ0RxEalJ8yxe/78vM+5tHQmmKT4T+UzZvFU9Ds7e7 8x+D0AsFsIMFTcBtW2/vAuebBvYOQKq4k670oDvDAWkNMowaCFmFTsWrP/1iW2HlQtOK 0+zRLX0De1EeIxmvtD4nernVthMJLQcvoYQSxTie20MpqmQ0UycerImi81UYoToQbTfL bvLg== X-Gm-Message-State: AOUpUlE/3uyJGDLaVusyWW6qvKyVcZqptZ3e/PMsc4XQ/RUTyFNm+I+2 pzaZGj9je0ksX78mEwiu0SIsrY+zVVw= X-Google-Smtp-Source: AAOMgpfZKOjiL1DUYHUns1nnV3pmwAQhxP6zYn6cmcxEqnLU0UvMnUBy1IWsHt3NZeElfQL5QEm9UQ== X-Received: by 2002:a63:a44a:: with SMTP id c10-v6mr7261837pgp.198.1531949882233; Wed, 18 Jul 2018 14:38:02 -0700 (PDT) Received: from localhost ([2405:204:1408:e6f0:4529:2779:e150:51d8]) by smtp.gmail.com with ESMTPSA id d9-v6sm9155364pfb.86.2018.07.18.14.38.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 14:38:00 -0700 (PDT) From: Bhupesh Sharma To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64, kaslr: export offset in VMCOREINFO ELF notes Date: Thu, 19 Jul 2018 03:07:44 +0530 Message-Id: <1531949864-27447-1-git-send-email-bhsharma@redhat.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180718_143813_281341_79FA595B X-CRM114-Status: GOOD ( 13.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Ard Biesheuvel , Will Deacon , Bhupesh Sharma , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, takahiro.akashi@linaro.org, James Morse , Catalin Marinas , bhupesh.linux@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Include KASLR offset in VMCOREINFO ELF notes to assist in debugging. makedumpfile user-space utility will need fixup to use this KASLR offset to work with cases where we need to find a way to translate symbol address from vmlinux to kernel run time address in case of KASLR boot on arm64. I already have those fixup ready, which will be sent upstream once this patch makes through (see [0]). I tested this on my qualcomm amberwing board both for KASLR and non-KASLR boot cases: Without this patch: # cat > scrub.conf << EOF [vmlinux] erase jiffies erase init_task.utime for tsk in init_task.tasks.next within task_struct:tasks erase tsk.utime endfor EOF # makedumpfile --split -d 31 -x vmlinux --config scrub.conf vmcore dumpfile_{1,2,3} readpage_elf: Attempt to read non-existent page at 0xffffa8a5bf180000. readmem: type_addr: 1, addr:ffffa8a5bf180000, size:8 vaddr_to_paddr_arm64: Can't read pgd readmem: Can't convert a virtual address(ffff0000092a542c) to physical address. readmem: type_addr: 0, addr:ffff0000092a542c, size:390 check_release: Can't get the address of system_utsname After this patch check_release() is ok, and also we are able to erase symbol from vmcore (I checked this with kernel 4.18.0-rc4+): # makedumpfile --split -d 31 -x vmlinux --config scrub.conf vmcore dumpfile_{1,2,3} The kernel version is not supported. The makedumpfile operation may be incomplete. Checking for memory holes : [100.0 %] \ Checking for memory holes : [100.0 %] | Checking foExcluding unnecessary pages : [100.0 %] \ Excluding unnecessary pages : [100.0 %] \ The dumpfiles are saved to dumpfile_1, dumpfile_2, and dumpfile_3. makedumpfile Completed. [0] https://github.com/bhupesh-sharma/makedumpfile/commit/555e5ae0fb2b21797c450ad55950e81c470224ef Cc: Ard Biesheuvel Cc: Will Deacon Cc: Mark Rutland Cc: Catalin Marinas Cc: James Morse Signed-off-by: Bhupesh Sharma --- arch/arm64/kernel/machine_kexec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index f62effc6e064..028df356a5fd 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -360,4 +360,5 @@ void arch_crash_save_vmcoreinfo(void) kimage_voffset); vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n", PHYS_OFFSET); + vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset()); }