Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8519931ybc; Fri, 29 Nov 2019 12:01:24 -0800 (PST) X-Google-Smtp-Source: APXvYqzUXiG1oWg0WzB+Uiveu3wGHTEwuhEbeR24HiMh2DvcL2IBOyMzYx26sfcmz3/2AUO0J2a4 X-Received: by 2002:a17:906:4098:: with SMTP id u24mr62194654ejj.220.1575057683456; Fri, 29 Nov 2019 12:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575057683; cv=none; d=google.com; s=arc-20160816; b=ZHJonm44zynQvo20Z5frDMngNhobJv4DXxbDg+y9er0pwRv6vmU2tJM6MrgZDkEIl3 SazBdMZTaa1nrVIf8NU2gFPTQiMvddK3AMPqGV+owZNM38R2RkJecGzfO/iKqvSXO0xy 80uWRYIxzAOcvHr/bWc8YOe01zFQmZFkH1H7r68IjPd07fWVVa5wQ+XeH8dON9x/L63d 2gsDkO69oY33iWFIjAKKWttXmCfrVlyLffXuftipsebS5Vz55MitXnVuFYuA0JLiQwQu UwPMzgbruaY13ovHXfFyxrJHOhPVyjRbTKyg+tqrRwhNScjqbqylD35BP9fX9nnXeBUi 0e4Q== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=wgbAkKrJxLS1NEOR+82/qBcYhhrIFUtkNwc9k9kwPFE=; b=YUZMBXWrFMZju10MBQZxmmF7ymduIfS8HOaYnXdPmkPHmWJbqMzx6JEGzETkDAj62s a6a0UomioNkN7F/9XMJDdF4UKJ4it38HhYn2jxYon7jlRefLwD11zDOZ53NeC4YqfEMD SkabLSmIgOhOc1J7WYPlRFQXwgehCIuT/ki3/YyghrG/90mLAlT30CDtXaW6slSolUuM 1UiMNlSbcCL7td/yfk1dXWQaVOpQPaw3vFOJN/3p5+cf9WLDUXM8hoUSpL9dlVzNjFo+ 6H3TfmbdDlJw9H+gfHCCf5JrwGoPoABQ/pX3V5F4hdS9p5A5zVvl5yJtJegVXGdk7bDu hn+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ptf/TCYZ"; 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=pass (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 t7si7806320ejs.17.2019.11.29.12.00.55; Fri, 29 Nov 2019 12:01:23 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ptf/TCYZ"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727166AbfK2T7r (ORCPT + 99 others); Fri, 29 Nov 2019 14:59:47 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:43974 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727107AbfK2T7q (ORCPT ); Fri, 29 Nov 2019 14:59:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575057584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wgbAkKrJxLS1NEOR+82/qBcYhhrIFUtkNwc9k9kwPFE=; b=Ptf/TCYZpNUNBaJhgOdr4X7qUTDzH/XvQfUWPLBa/z/RuVThOqvtXr32eiyH4t1qDRLuzz U/nb6MDzKc9D4pxkmgnsGPcxUMkNN2WhYlYs9jkGxQ1QsL/MiK4yfOVIzvUGnaB8fIb2A3 JWNsUiXKfOY7NcS1POS88HN1HBZfsLo= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-tPeAjtb5NkGRcrBbNoqjCA-1; Fri, 29 Nov 2019 14:59:42 -0500 Received: by mail-pj1-f69.google.com with SMTP id c23so15213476pjs.16 for ; Fri, 29 Nov 2019 11:59:41 -0800 (PST) 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=iJyjrUFfcmHAhH3JG4K3fZfDXNCj7aMMhMdC/cxhP5Q=; b=E46VILfpMQNIbNpu84a1LQRJpQx9tXq7qNP9LWqqLz0Rh/P8sVTw89Y0Wffb5/3PM/ tOOfodXV2RmK9ZoPnGfjR/+VBmlglkd+76FtVJPya9Co5dOiC6HiW21rf2YZzD5//8DI uiJCSNnZuTPBh/GFmQQdfb1DRsAldeEk2ydqctEMjR9VHWRPGIU4Wofd41GbofjWq/xr 0xzuwKpVHuPDhiuk4RdK3C6dL3FU1eF8nv/zfApOicQMG+cd8imhJ4B8lBxWt50FarHJ M+C6E03iMDQHJrbJytS76ZIFXn+KzvphNyHa0Fg4D5brTUJCROIue6xre7AoItp/Ak2I gUdA== X-Gm-Message-State: APjAAAWc9aptVT8o2c3nH3zkrQPMXfV4cTZxA2KhFtta4viScJSv5Cv/ p3QJM83LWL7qDcYtrErez4s5yG8mrR9Nu0y+Zfeiq3WkCNbo1i6T8lm8Xfl9k/hSuQnAnBSVI2P 8GzHN1mSL50sT1bp2AQHVq5La X-Received: by 2002:a63:fb03:: with SMTP id o3mr18525465pgh.378.1575057580571; Fri, 29 Nov 2019 11:59:40 -0800 (PST) X-Received: by 2002:a63:fb03:: with SMTP id o3mr18525441pgh.378.1575057580274; Fri, 29 Nov 2019 11:59:40 -0800 (PST) Received: from localhost ([122.177.85.74]) by smtp.gmail.com with ESMTPSA id jx12sm6300003pjb.26.2019.11.29.11.59.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 11:59:39 -0800 (PST) From: Bhupesh Sharma To: linux-kernel@vger.kernel.org Cc: bhsharma@redhat.com, bhupesh.linux@gmail.com, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kexec@lists.infradead.org, James Morse , Mark Rutland , Will Deacon , Steve Capper , Catalin Marinas , Ard Biesheuvel , Dave Anderson , Kazuhito Hagio Subject: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo Date: Sat, 30 Nov 2019 01:29:16 +0530 Message-Id: <1575057559-25496-3-git-send-email-bhsharma@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575057559-25496-1-git-send-email-bhsharma@redhat.com> References: <1575057559-25496-1-git-send-email-bhsharma@redhat.com> X-MC-Unique: tPeAjtb5NkGRcrBbNoqjCA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/write this value from/to vmcoreinfo for determining if a virtual address lies in the linear map range. The user-space computation for determining whether an address lies in the linear map range is the same as we have in kernel-space: #define __is_lm_address(addr)=09(!(((u64)addr) & BIT(vabits_actual - 1))) I have sent out user-space patches for makedumpfile and crash-utility to add features for obtaining vabits_actual value from TCR_EL1.T1SZ (see [0] and [1]). Akashi reported that he was able to use this patchset and the user-space changes to get user-space working fine with the 52-bit kernel VA changes (see [2]). [0]. http://lists.infradead.org/pipermail/kexec/2019-November/023966.html [1]. http://lists.infradead.org/pipermail/kexec/2019-November/024006.html [2]. http://lists.infradead.org/pipermail/kexec/2019-November/023992.html 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 Signed-off-by: Bhupesh Sharma --- arch/arm64/include/asm/pgtable-hwdef.h | 1 + arch/arm64/kernel/crash_core.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/as= m/pgtable-hwdef.h index d9fbd433cc17..d2e7aff5821e 100644 --- a/arch/arm64/include/asm/pgtable-hwdef.h +++ b/arch/arm64/include/asm/pgtable-hwdef.h @@ -215,6 +215,7 @@ #define TCR_TxSZ(x)=09=09(TCR_T0SZ(x) | TCR_T1SZ(x)) #define TCR_TxSZ_WIDTH=09=096 #define TCR_T0SZ_MASK=09=09(((UL(1) << TCR_TxSZ_WIDTH) - 1) << TCR_T0SZ_OF= FSET) +#define TCR_T1SZ_MASK=09=09(((UL(1) << TCR_TxSZ_WIDTH) - 1) << TCR_T1SZ_OF= FSET) =20 #define TCR_EPD0_SHIFT=09=097 #define TCR_EPD0_MASK=09=09(UL(1) << TCR_EPD0_SHIFT) diff --git a/arch/arm64/kernel/crash_core.c b/arch/arm64/kernel/crash_core.= c index ca4c3e12d8c5..f78310ba65ea 100644 --- a/arch/arm64/kernel/crash_core.c +++ b/arch/arm64/kernel/crash_core.c @@ -7,6 +7,13 @@ #include #include =20 +static inline u64 get_tcr_el1_t1sz(void); + +static inline u64 get_tcr_el1_t1sz(void) +{ +=09return (read_sysreg(tcr_el1) & TCR_T1SZ_MASK) >> TCR_T1SZ_OFFSET; +} + void arch_crash_save_vmcoreinfo(void) { =09VMCOREINFO_NUMBER(VA_BITS); @@ -15,5 +22,7 @@ void arch_crash_save_vmcoreinfo(void) =09=09=09=09=09=09kimage_voffset); =09vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=3D0x%llx\n", =09=09=09=09=09=09PHYS_OFFSET); +=09vmcoreinfo_append_str("NUMBER(tcr_el1_t1sz)=3D0x%llx\n", +=09=09=09=09=09=09get_tcr_el1_t1sz()); =09vmcoreinfo_append_str("KERNELOFFSET=3D%lx\n", kaslr_offset()); } --=20 2.7.4