Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp403090ybt; Wed, 1 Jul 2020 01:04:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKDTjdVE3Tq7hqaYXfbEPLw+aopZ/3xZj3ySv+Ea9zMu+K8A0dt4/L/CL9eeVWAfImiedt X-Received: by 2002:a17:906:511:: with SMTP id j17mr18392508eja.434.1593590683991; Wed, 01 Jul 2020 01:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593590683; cv=none; d=google.com; s=arc-20160816; b=uiOM+/bZQUihEHmqFrDXHgEVU6KxqPNoWsPE/dY+0RheeNpXuLkQwew0X5LdSJc3q2 aeSmLudCl4F7KdUPw4f6kQEdmceE/yikcpU2+ptExC4YIiZVlFsjwP6mUoagygjT/Gp7 PyPrlgmNW33aizxnHJsIE50svxTmDamc4z754VO+/blo5Rvq4cilcYXAClBTsJCZWNgo KL9uJmfMGcdiH3N9R+DEwxjUd9rEqGnkp7CdZ7tGqvKxJrZtuLrW1GbKQbEeUgIFEgon Gtd4F2r1Of+FHqRQMRH5W0EAfz2pnj4czrECrmYpTZry6PIX4QBAs27zs0hHEOeBiaqB blNg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=CuoyPdxsc5uzpSLKzlBB6gdzp5wDu6Rxi/R1zBXj5HU=; b=abptXjayga6sHLoao8CmCoZvYbavGqAYEMXW6x3Rfi+CA37gIJKRKKGCJD6EqqyyRz Fqu6ySnF79jecwe4eOEkkX83HCrGebT7A/XTaq2piE9h9dC7UeOeoqBgceDqvi9G5M7/ kdQgRv6VFR80xa+Eh1LDPQbnIZECd1RbE9HlHmS3nc4mhcj3f9H0TGjH7pJQ8GE0cMzW 22PHWhcEeE0R7hbPeOUip7HaU7aH3CH93hvd67LVdEk0NsVRmxPqlSQsFZXwisfu+nYb UlHxGeqGTTg3hIzEa+nRYe+dxp32+OQnUq5S7/FUO4Ov8o6Iw2L20bCU+WMMGP4WOssP ms7Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk3si3490632ejb.323.2020.07.01.01.04.20; Wed, 01 Jul 2020 01:04:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728502AbgGAIEM (ORCPT + 99 others); Wed, 1 Jul 2020 04:04:12 -0400 Received: from foss.arm.com ([217.140.110.172]:41924 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728258AbgGAIEJ (ORCPT ); Wed, 1 Jul 2020 04:04:09 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 62B9B31B; Wed, 1 Jul 2020 01:04:07 -0700 (PDT) Received: from [10.57.4.20] (unknown [10.57.4.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2AD43F68F; Wed, 1 Jul 2020 01:04:03 -0700 (PDT) Subject: Re: [PATCH v6 2/2] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo To: Bhupesh Sharma , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: Mark Rutland , Kazuhito Hagio , Steve Capper , Catalin Marinas , Ard Biesheuvel , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse , Dave Anderson , bhupesh.linux@gmail.com, Will Deacon References: <1589395957-24628-1-git-send-email-bhsharma@redhat.com> <1589395957-24628-3-git-send-email-bhsharma@redhat.com> From: Amit Kachhap Message-ID: <9b44a21d-93e0-8e5d-019c-fd360bf0504b@arm.com> Date: Wed, 1 Jul 2020 13:34:00 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1589395957-24628-3-git-send-email-bhsharma@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bhupesh, On 5/14/20 12:22 AM, Bhupesh Sharma wrote: > vabits_actual variable on arm64 indicates the actual VA space size, > and allows a single binary to support both 48-bit and 52-bit VA > spaces. > > If the ARMv8.2-LVA optional feature is present, and we are running > with a 64KB page size; then it is possible to use 52-bits of address > space for both userspace and kernel addresses. However, any kernel > binary that supports 52-bit must also be able to fall back to 48-bit > at early boot time if the hardware feature is not present. > > Since TCR_EL1.T1SZ indicates the size offset of the memory region > addressed by TTBR1_EL1 (and hence can be used for determining the > vabits_actual value) it makes more sense to export the same in > vmcoreinfo rather than vabits_actual variable, as the name of the > variable can change in future kernel versions, but the architectural > constructs like TCR_EL1.T1SZ can be used better to indicate intended > specific fields to user-space. > > User-space utilities like makedumpfile and crash-utility, need to > read this value from vmcoreinfo for determining if a virtual > address lies in the linear map range. > > While at it also add documentation for TCR_EL1.T1SZ variable being > added to vmcoreinfo. > > It indicates the size offset of the memory region addressed by TTBR1_EL1 > > Cc: James Morse > Cc: Mark Rutland > Cc: Will Deacon > Cc: Steve Capper > Cc: Catalin Marinas > Cc: Ard Biesheuvel > Cc: Dave Anderson > Cc: Kazuhito Hagio > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Cc: kexec@lists.infradead.org > Tested-by: John Donnelly > Signed-off-by: Bhupesh Sharma I tested this for both 48 and 52 VA. The dump log looks fine with the crash tool link provided by you so, Tested-by: Amit Daniel Kachhap Also the code changes/documentation looks fine to me with a minor comments below, Reviewed-by: Amit Daniel Kachhap > --- > Documentation/admin-guide/kdump/vmcoreinfo.rst | 11 +++++++++++ > arch/arm64/include/asm/pgtable-hwdef.h | 1 + > arch/arm64/kernel/crash_core.c | 10 ++++++++++ > 3 files changed, 22 insertions(+) > > diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst > index 2a632020f809..2baad0bfb09d 100644 > --- a/Documentation/admin-guide/kdump/vmcoreinfo.rst > +++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst > @@ -404,6 +404,17 @@ KERNELPACMASK > The mask to extract the Pointer Authentication Code from a kernel virtual > address. > > +TCR_EL1.T1SZ > +------------ > + > +Indicates the size offset of the memory region addressed by TTBR1_EL1. > +The region size is 2^(64-T1SZ) bytes. > + > +TTBR1_EL1 is the table base address register specified by ARMv8-A > +architecture which is used to lookup the page-tables for the Virtual > +addresses in the higher VA range (refer to ARMv8 ARM document for > +more details). > + > arm > === > > diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h > index 6bf5e650da78..a1861af97ac9 100644 > --- a/arch/arm64/include/asm/pgtable-hwdef.h > +++ b/arch/arm64/include/asm/pgtable-hwdef.h > @@ -216,6 +216,7 @@ > #define TCR_TxSZ(x) (TCR_T0SZ(x) | TCR_T1SZ(x)) > #define TCR_TxSZ_WIDTH 6 > #define TCR_T0SZ_MASK (((UL(1) << TCR_TxSZ_WIDTH) - 1) << TCR_T0SZ_OFFSET) > +#define TCR_T1SZ_MASK (((UL(1) << TCR_TxSZ_WIDTH) - 1) << TCR_T1SZ_OFFSET) > > #define TCR_EPD0_SHIFT 7 > #define TCR_EPD0_MASK (UL(1) << TCR_EPD0_SHIFT) > diff --git a/arch/arm64/kernel/crash_core.c b/arch/arm64/kernel/crash_core.c > index 1f646b07e3e9..314391a156ee 100644 > --- a/arch/arm64/kernel/crash_core.c > +++ b/arch/arm64/kernel/crash_core.c > @@ -7,6 +7,14 @@ > #include > #include > #include > +#include Nit: May be you forgot to include here as suggested by James in v5. Cheers, Amit > + > +static inline u64 get_tcr_el1_t1sz(void); > + > +static inline u64 get_tcr_el1_t1sz(void) > +{ > + return (read_sysreg(tcr_el1) & TCR_T1SZ_MASK) >> TCR_T1SZ_OFFSET; > +} > > void arch_crash_save_vmcoreinfo(void) > { > @@ -16,6 +24,8 @@ void arch_crash_save_vmcoreinfo(void) > kimage_voffset); > vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n", > PHYS_OFFSET); > + vmcoreinfo_append_str("NUMBER(TCR_EL1_T1SZ)=0x%llx\n", > + get_tcr_el1_t1sz()); > vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset()); > vmcoreinfo_append_str("NUMBER(KERNELPACMASK)=0x%llx\n", > system_supports_address_auth() ? >