From patchwork Fri Nov 29 19:59:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 11267579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74204139A for ; Fri, 29 Nov 2019 20:00:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 380412158A for ; Fri, 29 Nov 2019 20:00:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nItL+Dns"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ptf/TCYZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 380412158A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=rQUeEhnxe/fnikXZQt1i7+hvd8Og3QYtZI9n8u2JF1A=; b=nItL+DnsyXAmrDRFM630+BI7GB QQyxU4xlNawPxkkfbpGf5yB4xUstQxwebRBkhoelFkUgaFc3izlUoSPLZfLzjI9ZBiSU7XH3Mettd hzM1GbttrTmwDpNA3NFL9LbwuJ4WefOgvNMj34lg4LdOXmaOSRHUwokLewu7yM/Dhm2g+fffFe3+Z xzCKvNB8CotbzViPZmZC+iyOhV4KVqgQNxMJbeBqr00YMOKtAdoj4Fy3qP3qEu03HQ5VTsS7jI1Ml ji4L083vbUSwRN06tEZoX0SYUlNG4mIHB52nFAFaf2P1q6H9UqUDAtkbRGeSMDdnTm9DpPBeWRvQ+ 11+oZ/cQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iamRR-0000cW-2z; Fri, 29 Nov 2019 20:00:37 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iamQc-00079e-7O for linux-arm-kernel@lists.infradead.org; Fri, 29 Nov 2019 19:59:48 +0000 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-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-7QbnBYmzP2W_XcwRNvTJqA-1; Fri, 29 Nov 2019 14:59:41 -0500 Received: by mail-pg1-f200.google.com with SMTP id o21so1659911pgm.11 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=ap8/vnF6lY49WE19fhzYrbMORqAuyFmzQOXe7IJ+ATGpHf387A9S3yD3ebJ9jEy2KM nmhynqelQ4RYNNTbtNd2ZkYOltJoLL+ulFdUYcHj+hT7C4/4eSZ9Xnehvrvee8SJtJKC 4muZf/AVOOo/qROMkfr0FpNF9RJyNKwhvfER18rGwirFGOlfp75rPD/WoUNr/IwOKjpq JbQLNT3GTuA7T8sNY+30vZy6I6PRCf5yq39UaC0/9tl0RAciUnSrk/xm5HE3dOZqb+js E/Yd7MYzTUm1gTcIvE+BcVcvTqWgIVoypbaBV+JLdZTJYpW0ofj6H8pFK79Zp0yjQerd /M2Q== X-Gm-Message-State: APjAAAUWar88ZNDSoRR0jGFpCRO9aeKi5I+YpM6KOyWonSWXYvJFV3LT PpYtlnRp739UpKUpPtgey+7x1jgnN7hsoUStDLQBjjZtIfYeDTDS75LT27zhoZUEuYVcO45BTw4 ZfFj/KwaxS7PcGfUo4taFuLLaL7fxDahkUk8= X-Received: by 2002:a63:fb03:: with SMTP id o3mr18525468pgh.378.1575057580572; Fri, 29 Nov 2019 11:59:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxSS9+ZN7GKT/MIwc8aGAoCV6a/ldIDRYJOYbBvx5BLhqOQbU8FUr1Poz3Dix0kBpRLDW39Sw== 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 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: 7QbnBYmzP2W_XcwRNvTJqA-1 X-Mimecast-Spam-Score: 0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191129_115946_390595_9C65B5EF X-CRM114-Status: GOOD ( 18.37 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Ard Biesheuvel , linux-doc@vger.kernel.org, Will Deacon , bhsharma@redhat.com, x86@kernel.org, kexec@lists.infradead.org, Kazuhito Hagio , James Morse , Catalin Marinas , Dave Anderson , bhupesh.linux@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, Steve Capper MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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) (!(((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/asm/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) (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 ca4c3e12d8c5..f78310ba65ea 100644 --- a/arch/arm64/kernel/crash_core.c +++ b/arch/arm64/kernel/crash_core.c @@ -7,6 +7,13 @@ #include #include +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) { VMCOREINFO_NUMBER(VA_BITS); @@ -15,5 +22,7 @@ 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()); }