From patchwork Sun Mar 10 10:04:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 10846267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 027571823 for ; Sun, 10 Mar 2019 10:05:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA1EF287E3 for ; Sun, 10 Mar 2019 10:05:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA2B928FD3; Sun, 10 Mar 2019 10:05:18 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 61C29287E3 for ; Sun, 10 Mar 2019 10:05:18 +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:References: In-Reply-To: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:List-Owner; bh=bXTamvLeEKky52bpv2aF7gvKogsfbYPKdsB2vWKO5uA=; b=J4eGGF5QzvhtLKu+V7gFE48OxO IjgQ+0XN92wq4JU+eT7cSqw2kFQvmUwdaIsW9DTzjhaQqv8oB5d4X2wyeBSqnhfCVN5at1w4hOK1/ LdYAOj/pcx42L7vqPLPJ9/RJ026cO8nq4aomPlynk+367l7NXkYLcXncNtZtwybZ77+SOmuOBrNUS kaKjKNUHj4WMvFLquQW51dEaF3kuLy2SqW4VGzI3kaZf85UP/W3GRPvGJha8dOLz7sTKjm1MWcIGE ZZPDA8lD1tSsHjZkGAOoztWfwX7k62Mjsnz8b4JyqVLurzP2bpJa4kjqFRjNqHoqYuXB+wOmcXLj9 5ywVmfJw==; 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 1h2vKW-00006n-8e; Sun, 10 Mar 2019 10:05:16 +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 1h2vKD-0007Nv-9B for linux-arm-kernel@lists.infradead.org; Sun, 10 Mar 2019 10:04:59 +0000 Received: by mail-pg1-f193.google.com with SMTP id e17so1716929pgd.2 for ; Sun, 10 Mar 2019 03:04:57 -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:in-reply-to :references; bh=p0woFonxhQQij4xaUhXjp4CHNytg0N40QAtCXayEoro=; b=gSBby2POSom+V8+yen9eZm3nlpTwaSn/k6nBjhh8chHcI9Sk9UPFlK2zAZTJxqFAl2 LAdptrMCkVcxnbvY0WQ62Oh6np0xm+GlsQQuh4/b36kS0N2LJC+ynk3v3zdKywt7Reqc M0DZwrrnwLBGri0pRkikABaCDskNKt/WswxiEuZzR7LRsCCMoDvEP/vRUbz5Cjzro/mQ QnE5MpkuQPuPqJSaaAbqEX9fce+UwAs4z+hubrJMDai7qqn5425OEqxEEuWl0ZGBTToY y1rGMVxPJ9K+7x/gCg281pFFD756pbmXZUBbS4XGIGdNZZctJy48RnUM9FSwSQ0vBXUs ei7A== X-Gm-Message-State: APjAAAWrcm14c+kjXA+WlgPY5tVdIA3E/WcIP6Rg7tNK5gea2MitlTPQ BMPCT/H/CDMkPzTJhInAMpBrPg== X-Google-Smtp-Source: APXvYqzZOzpXKDW58QolX8yBU9HTROhz294pagdWcO/uzW7wcBeI+NRVaXE6VKdHz/9a1S/CymETIw== X-Received: by 2002:a17:902:4081:: with SMTP id c1mr28394637pld.297.1552212296851; Sun, 10 Mar 2019 03:04:56 -0700 (PDT) Received: from localhost ([106.215.118.61]) by smtp.gmail.com with ESMTPSA id r6sm3380076pgp.46.2019.03.10.03.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Mar 2019 03:04:56 -0700 (PDT) From: Bhupesh Sharma To: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] arm64, vmcoreinfo : Append 'PTRS_PER_PGD' to vmcoreinfo Date: Sun, 10 Mar 2019 15:34:01 +0530 Message-Id: <1552212242-9479-2-git-send-email-bhsharma@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552212242-9479-1-git-send-email-bhsharma@redhat.com> References: <1552212242-9479-1-git-send-email-bhsharma@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190310_030457_430222_F829A887 X-CRM114-Status: GOOD ( 13.72 ) 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 , Kazuhito Hagio , kexec@lists.infradead.org, bhsharma@redhat.com, Will Deacon , James Morse , Dave Anderson , bhupesh.linux@gmail.com, linux-arm-kernel@lists.infradead.org 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 With ARMv8.2-LVA architecture extension availability, arm64 hardware which supports this extension can support a virtual address-space upto 52-bits. Since at the moment we enable the support of this extension in kernel via CONFIG flags, e.g. - User-space 52-bit LVA via CONFIG_ARM64_USER_VA_BITS_52 so, there is no clear mechanism in the user-space right now to determine these CONFIG flag values and hence determine the maximum virtual address space supported by the underlying kernel. User-space tools like 'makedumpfile' therefore are broken currently as they have no proper method to calculate the 'PTRS_PER_PGD' value which is required to perform a page table walk to determine the physical address of a corresponding virtual address found in kcore/vmcoreinfo. If one appends 'PTRS_PER_PGD' number to vmcoreinfo for arm64, it can be used in user-space to determine the maximum virtual address supported by underlying kernel. A reference 'makedumpfile' implementation which uses this approach to determining the maximum physical address is available in [0]. [0]. https://github.com/bhupesh-sharma/makedumpfile/blob/52-bit-va-support-via-vmcore-upstream-v3/arch/arm64.c#L459 Cc: Mark Rutland Cc: Will Deacon Cc: James Morse Cc: Dave Anderson Cc: Kazuhito Hagio Cc: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Suggested-by: Steve Capper Signed-off-by: Bhupesh Sharma --- arch/arm64/kernel/crash_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/crash_core.c b/arch/arm64/kernel/crash_core.c index ca4c3e12d8c5..123a42c56b8e 100644 --- a/arch/arm64/kernel/crash_core.c +++ b/arch/arm64/kernel/crash_core.c @@ -10,6 +10,7 @@ void arch_crash_save_vmcoreinfo(void) { VMCOREINFO_NUMBER(VA_BITS); + VMCOREINFO_NUMBER(PTRS_PER_PGD); /* Please note VMCOREINFO_NUMBER() uses "%d", not "%x" */ vmcoreinfo_append_str("NUMBER(kimage_voffset)=0x%llx\n", kimage_voffset); From patchwork Sun Mar 10 10:04:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 10846269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5152D1390 for ; Sun, 10 Mar 2019 10:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F227287E3 for ; Sun, 10 Mar 2019 10:05:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2092728FD2; Sun, 10 Mar 2019 10:05:37 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 A8DAC287E3 for ; Sun, 10 Mar 2019 10:05:36 +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:References: In-Reply-To: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:List-Owner; bh=3p8tKXQNMEIgJB0Xi1Sn/O13YkX/vEPys1cgAZujqDQ=; b=M/uJQMzEikZQ043OUTvbI7qR/E /66uZroa92F6FIRheAbOeogGBe3Ezc9loMBihbHb+XltN7etPnXzDFzoVWe8p6nolf1KHvYxrIucD M3fQlYPvxv7JaWsYZghrrEH5FPm6BbMluszhDSnyqMnYIC2R3avAAhjH1xY6k5yP/CE56/2G+O9LN zaugeAW4gX5/2N6Q/jFkqT8CKw+LAvlVIdKrsll8BsoQLBxRUfQLrza8+SHGckGCqIQYtbVZZY6mP z23PhvJi0eIzmclgMYkw93Sd7t7+9xQeG0DnP2gm0DJlsWwEH6prJeX3btnOYVpdGNcgGcuQ1TvYr 0+VKJyWA==; 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 1h2vKo-0000kX-Ph; Sun, 10 Mar 2019 10:05:34 +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 1h2vKI-0007Uo-T3 for linux-arm-kernel@lists.infradead.org; Sun, 10 Mar 2019 10:05:09 +0000 Received: by mail-pg1-f193.google.com with SMTP id h11so1721384pgl.0 for ; Sun, 10 Mar 2019 03:05:02 -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:in-reply-to :references; bh=L1C+T2uli6R0dd/vYObZu3h9qXje3TBmGHmavCoixHE=; b=qk6R3GVa/h2L6qeH3rkIwm4Wf4fYxWEOdui2He59FGV3J9yL3U/0xhSQxC0xjiWJFF v6yrvlhZ5jC+YodsAh3Rx+0luETNzjOOCO72ithSCqS/24/eAkIFa1ocrM1NFBEf6hgR VqI5U2lrZg0MUK9wIQ5CdSLewrSduEnSX+uIL+6wlxkjxFKbWVJYkgcElUk8W1nqqc55 lXFTpFZE48ExE35MmbcHzLusl4/8JASeFM+70nN7VKiuIRqfFTW3ppT0F1r4vSSxDdx2 F4g0VKHHwjenXbxnKzFmGBk08jv9kEigID4JreMd+xvrVxHR/F8N0Vn3xez6O9pHmDMV Jmtw== X-Gm-Message-State: APjAAAUkdouXvJR/t83DFt8E/nXCZRegRcBpB7kbDO+HpIclLicgbLxw NEoXewXRH4+yE3lVY9+kVF9gWA== X-Google-Smtp-Source: APXvYqz8b9xjsFFZhd8G7xPoAENZwwwAhyiJlWkWEOR5IOWPW8b/pqUd6GSXZ5C0atZumHSeryF4cQ== X-Received: by 2002:a63:cd06:: with SMTP id i6mr25240388pgg.267.1552212301991; Sun, 10 Mar 2019 03:05:01 -0700 (PDT) Received: from localhost ([106.215.118.61]) by smtp.gmail.com with ESMTPSA id e26sm3979010pfd.124.2019.03.10.03.05.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Mar 2019 03:05:01 -0700 (PDT) From: Bhupesh Sharma To: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] crash_core, vmcoreinfo: Append 'MAX_PHYSMEM_BITS' to vmcoreinfo Date: Sun, 10 Mar 2019 15:34:02 +0530 Message-Id: <1552212242-9479-3-git-send-email-bhsharma@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552212242-9479-1-git-send-email-bhsharma@redhat.com> References: <1552212242-9479-1-git-send-email-bhsharma@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190310_030503_301678_18471E4B X-CRM114-Status: GOOD ( 15.55 ) 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: Kazuhito Hagio , Michael Ellerman , bhsharma@redhat.com, x86@kernel.org, Will Deacon , linuxppc-dev@lists.ozlabs.org, kexec@lists.infradead.org, James Morse , linux-arm-kernel@lists.infradead.org, Benjamin Herrenschmidt , Boris Petkov , Thomas Gleixner , bhupesh.linux@gmail.com, Dave Anderson , Ingo Molnar , Paul Mackerras 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 Right now user-space tools like 'makedumpfile' and 'crash' need to rely on a best-guess method of determining value of 'MAX_PHYSMEM_BITS' supported by underlying kernel. This value is used in user-space code to calculate the bit-space required to store a section for SPARESMEM (similar to the existing calculation method used in the kernel implementation): #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS) Now, regressions have been reported in user-space utilities like 'makedumpfile' and 'crash' on arm64, with the recently added kernel support for 52-bit physical address space, as there is no clear method of determining this value in user-space (other than reading kernel CONFIG flags). As per suggestion from makedumpfile maintainer (Kazu), it makes more sense to append 'MAX_PHYSMEM_BITS' to vmcoreinfo in the core code itself rather than in arch-specific code, so that the user-space code for other archs can also benefit from this addition to the vmcoreinfo and use it as a standard way of determining 'SECTIONS_SHIFT' value in user-land. A reference 'makedumpfile' implementation which reads the 'MAX_PHYSMEM_BITS' value from vmcoreinfo in a arch-independent fashion is available here: [0]. https://github.com/bhupesh-sharma/makedumpfile/blob/remove-max-phys-mem-bit-v1/arch/ppc64.c#L471 Cc: Boris Petkov Cc: Ingo Molnar Cc: Thomas Gleixner Cc: James Morse Cc: Will Deacon Cc: Michael Ellerman Cc: Paul Mackerras Cc: Benjamin Herrenschmidt Cc: Dave Anderson Cc: Kazuhito Hagio Cc: x86@kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org Signed-off-by: Bhupesh Sharma --- kernel/crash_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 093c9f917ed0..44b90368e183 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -467,6 +467,7 @@ static int __init crash_save_vmcoreinfo_init(void) #define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) VMCOREINFO_NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE); #endif + VMCOREINFO_NUMBER(MAX_PHYSMEM_BITS); arch_crash_save_vmcoreinfo(); update_vmcoreinfo_note();