Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1789943imm; Thu, 19 Jul 2018 07:56:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdPx5YtmvAGn1+uKbnCI2HqFgx+rKI/NtffO7amaohVTQoHPQ7hkafg/CMBIGwAbLbLs2L+ X-Received: by 2002:a62:3ece:: with SMTP id y75-v6mr9991386pfj.7.1532012204367; Thu, 19 Jul 2018 07:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532012204; cv=none; d=google.com; s=arc-20160816; b=Wu55MfCJz3mYCe0xUjiJPR0StyTNWhYNVXptu4PfKzrZDJ3SdoJi2OOl70D4stsB8b BtExYXQOkj+Ypns/AxSYN5YbR3qONIZOFMez0jVUPjIJY0gHvCnF0wDU4l/IRGs9zbsi iIH+XazbPBIIaNt8Wr+ucWKuQ8p1EcKlash9mPn49j235wzdOayi5qpm8EbIbbD1yApr mL/L+NzALMhW6herrdfOW5hRjIYmlxaxYlPLqPgYES+Fn06lMEVK6BKzciaLnQps9NE8 pdvqMh5A1mvZfAKXyMpunXbBGZNKIhlVO0qzxyK/51kjJGI2a4Vev19c26apfd1W8CDB LwxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=OWqGw9tF0JpE0p89oUlhFYfSLniOkh+1b4lYF5kF4gg=; b=LJb4toI+2ZuJg6IdaybHXyJ+qMRT2BeVsXx0jXtgaLuMhpUHqVEkDbrr3S4/pm86+w lZi9ktDHNWMXtOMBK+itv5QdQULPuloW2Ta+TQVoHgoMS6aAfiduOkX3vHJNstpnyO7a 7bKgn6zqu1+hZopTpK0W4QHLtbMq3zLE9TBLUCVpd44IxTS/rqqP4UghrHMKAFj1h2lu GJ6O9bIzVnn3drhrg3YrlNBBsTSr2T1MOsBOO2hCGPEdO2iwLlAkk8efzwkvVH61wJ2D YqfKkcKlpe4vLsoV/L12dgcfS/3omnr2CL3DRBatX0uOaoaBV8zLrrvj6f8C2TnbSsEv jXzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si5740146plf.453.2018.07.19.07.56.29; Thu, 19 Jul 2018 07:56:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731822AbeGSPjD (ORCPT + 99 others); Thu, 19 Jul 2018 11:39:03 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34406 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731236AbeGSPjC (ORCPT ); Thu, 19 Jul 2018 11:39:02 -0400 Received: by mail-lj1-f194.google.com with SMTP id f8-v6so7970258ljk.1 for ; Thu, 19 Jul 2018 07:55:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=OWqGw9tF0JpE0p89oUlhFYfSLniOkh+1b4lYF5kF4gg=; b=ug0xgjwuvT5j/oZ9CUe+UAClGO5GuLs3zqQTNFklUiwdkbnbWdUS82tI3LCHK11w19 pGnqDB3HbS3knoTnjeTT17iKG3wuW573S1j1x4/PZ/xOn4Eq+aFbS3hu95JA+RybKgTQ jH/bT4LmrnaT5f/dSWm7ZhQkatNermLKMt0ZRNAuzetCtybn7Rr6fF+Cux1OUEer5EvO 5IKLIAIB8zj0OGBiu2YatV5NZJMJhs4T4KRzxSthi+KNLbC9lv7Li2tfa6QopfdC1hVG isiZOzz43f79sMJgQNXSy3HvPSJ0f+kRimbPnNUXcUSUG0WZf57LA0LFhABAUL/VYm9G zq2Q== X-Gm-Message-State: AOUpUlEx/zDMMz0gr2nmocOUswfcZZkGBDVeI5ki5oc33Qd7Jgp0Zw6T I/Z/OvBcYF1mhxIcy0K0GjzR7zaYBHtr+BY9Dml/WA== X-Received: by 2002:a2e:4557:: with SMTP id s84-v6mr7836905lja.47.1532012128266; Thu, 19 Jul 2018 07:55:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:81a:0:0:0:0:0 with HTTP; Thu, 19 Jul 2018 07:55:27 -0700 (PDT) In-Reply-To: References: <1531949864-27447-1-git-send-email-bhsharma@redhat.com> From: Bhupesh Sharma Date: Thu, 19 Jul 2018 20:25:27 +0530 Message-ID: Subject: Re: [PATCH] arm64, kaslr: export offset in VMCOREINFO ELF notes To: James Morse Cc: linux-arm-kernel , Linux Kernel Mailing List , kexec mailing list , Bhupesh SHARMA , AKASHI Takahiro , Ard Biesheuvel , Will Deacon , Mark Rutland , Catalin Marinas Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, On Thu, Jul 19, 2018 at 5:01 PM, James Morse wrote: > Hi Bhupesh, > > On 18/07/18 22:37, Bhupesh Sharma wrote: >> 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. > > You need the kernel VA for a symbol. Isn't this what kallsyms is for? > | root@frikadeller:~# cat /proc/kallsyms | grep swapper_pg_dir > | ffff5404610d0000 B swapper_pg_dir Its already used by other archs like x86_64. See 'arch/x86/kernel/machine_kexec_64.c' : void arch_crash_save_vmcoreinfo(void) { <..snip..> vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset()); <..snip..> } Its just that we are enabling this feature for arm64 now that the KASLR boot cases are more widely seen on arm64 boards (as newer EFI firmware implementations are available which support EFI_RNG_PROTOCOL and hence KASLR boot). And we want existing user-space application(s) to work similarly on arm64 distributions as they work historically on other archs like x86_64 (in most cases the user-space user is not even aware, if he is developing for or using an underlying hardware which is arm64 or x86_64) > This is the KASLR address, the vmlinux has: > | root@frikadeller:~/linux/build_arm64# nm -s vmlinux | grep swapper_pg_dir > | ffff0000096d0000 B swapper_pg_dir > > > This is in the vmcoreinfo too, so you can work if out from the vmcore too: > | root@frikadeller:~# dd if=/proc/kcore bs=8K count=1 2>/dev/null | strings | > | grep swapper_pg_dir > | SYMBOL(swapper_pg_dir)=ffff5404610d0000 > > > I picked swapper_pg_dir, but you could use any of the vmcore:SYMBOL() addresses > to work out this offset. (you should expect the kernel to rename these symbols > at a whim). > Perhaps you missed what the above makedumpfile command was doing, so let me summarize again: The above makedumpfile command is trying to 'split' a vmcore file into smaller sub dumpfiles on the basis of some filtering rules. These rules are defined via a .conf file (scrub.conf in my example below). Lets see what MAKEDUMPFILE(8) documents about the '--split' option: --split Split the dump data to multiple DUMPFILEs in parallel. If specifying DUMPFILEs on different storage devices, a device can share I/O load with other devices and it reduces time for saving the dump data. The file size of each DUMPFILE is smaller than the system memory size which is divided by the number of DUMPFILEs. This feature supports only the kdump-compressed format. So, this use-case expects 'vmlinux' and 'vmcore' as mandatory inputs. Now, coming back to the use-case: # makedumpfile --split -d 31 -x vmlinux --config scrub.conf vmcore dumpfile_{1,2,3} Here, 'scrub.conf ' is defined to erase symbols 'jiffies', 'init_task.utime' and 'tsk.utime' # 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 This is usually used to erase company-confidential or non-important symbols from a vmcore before handing it over to a debugger (which uses this vmcore to determine the root-cause of a crash) - as there can be some sensitive symbols which a reporter may not want the debugger to read. So, in this use case both vmlinux (which contains the symbols) and vmcore are mandatory inputs and we cannot kallsyms. as it breaks the existing user-space use-cases and the .conf file can be user-defined (and hence he can pick any symbol/functions which might not even be present in 'kallsyms'). So no we cannot use 'kallsyms' here. Thanks, Bhupesh