Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp814198ybk; Wed, 13 May 2020 13:55:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt+/Refv+jLcRCmVvIluv3RQT6xf2aYp0aER/VE50zAMzSRff9xo1mBrTr9nL9Zki2+8vq X-Received: by 2002:a50:cccc:: with SMTP id b12mr1385593edj.68.1589403307910; Wed, 13 May 2020 13:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589403307; cv=none; d=google.com; s=arc-20160816; b=MDB4+sPqrWsoLhOltgMmWBMMDirsq2vjN+bk/yGAIy42N/ve8npDwVYsgMnw+psQnA hGEfHAZDHig+vGkWfmUXZU542kEK5OMwLAboh4US8GGGPaXX+C2pnYNFL4BysrPaI6mI 3pc4ZjnxMJa01to9bLPPgyKcFJOCxUCSQ/cN/bAV5umtsu8wveokUEl5zOuyABloXUUD JLbgKrfhP6u1e2FTlHVDGRDvzG10Nb5UHURn7t19l6ifaTYZ9aASnd741W/aDFR+bKtd t2wTDEt6hs/+tIJy9VyeVSqmNz7t/JhuKovMyr6aJcIdRN5MKM2wPg7+wguVTTrecTJD S+OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=izj75eA8qUg9h4nL2GwzYuH/rvKXm4fOWTZ49lsEjYs=; b=HxyCwKDNf43Nu2iOtWgRHyFPDBM3AFmhZzpBHv7p8brr98Lxuf/FgTGvWnu9ZP+saQ UsASqaqm2rJJdMyRRRPx9x1uAmdopr9ruF4KoG27pRt4lns69w/2UhZnx+P/KzHnKsGi jsj9mPc9/lhbQ8Rmd8RAyOn89BBYEodt1+ZUlI+2eqk0UQb8uv1ZfHvnVT6wKWULVb9b WmyDMOzwgjaRIA7yOI68eH3JK/yX9rn6beYPRuW2e53UiLC1n0ov68HsGVqN/lHieGwm yajXAGfMO3jxiNt1kMX4pisj/QgD3u6jVng/g0kiemDMou0FgD5/Rm+gZjVQlUUZeXpB Qe1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DG0DErJT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo16si415897edb.537.2020.05.13.13.54.44; Wed, 13 May 2020 13:55:07 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DG0DErJT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390314AbgEMSwy (ORCPT + 99 others); Wed, 13 May 2020 14:52:54 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:28488 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732990AbgEMSww (ORCPT ); Wed, 13 May 2020 14:52:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589395970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=izj75eA8qUg9h4nL2GwzYuH/rvKXm4fOWTZ49lsEjYs=; b=DG0DErJTc7eJtloCX1FQ6hoym3Av6B5NizNNYs6BvJ5B5gmrQzONZ0FnEXEfMETGnLYH9C 9MyiIb9Et6rhMZLVXYdMVb2OaW2kZJlnlAptOT2I0+pAnzJJ6zbAOf9Y0eLCDQIqC32ZIs HsU+iu2tSXMtZ1kdUkiYOUhg4Yldzjs= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-7sMQR_M-PWSRQs2pZsIJDQ-1; Wed, 13 May 2020 14:52:49 -0400 X-MC-Unique: 7sMQR_M-PWSRQs2pZsIJDQ-1 Received: by mail-pg1-f199.google.com with SMTP id s188so299670pgc.17 for ; Wed, 13 May 2020 11:52:48 -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=izj75eA8qUg9h4nL2GwzYuH/rvKXm4fOWTZ49lsEjYs=; b=F+In5MG11yjk0HGPfmr28CBvozuoNCJluMIHKy87jSX+j9+5yMudRBrPwWYCK778YE nhevRcEduthwJpr5mk1CB+DONyYe7AxXezNmXFXA97cnqw9pW+SQNtatxpYrXXGlYJN5 mXyD06YTiHtWQkTTuTWl9ZGZx+yduvgLCsjke5nlJ6A5JIHcGb+2/RE7O6IgeAdkZq5D jW2p+9BzM1frsfNx2DwZE8sZalJZY+jyCranEbTwnKGH67hzD7H//ubIRB0Qw2Y8MriP K4aUgHYD6VwLbhsNRk4z2+F9LvLM6603VuMOVBbp2eftAortbEfefIglg0cSfQ4unrqP 7ilQ== X-Gm-Message-State: AGi0PuYQIcjEtSk30SJ7+13ZtpNyM7yCnKp5Zb96YsO2H7WY+6fWjf8v gJYRrZzJFIeV3BWFU1vr0/3xch4NEfooEqr2sBYxH69fjtbGXgMrfddMDxBTBuX6jbU8uPC5Iqn BDavY9Sbib3eWfTl/VUZlleye X-Received: by 2002:a17:90b:957:: with SMTP id dw23mr36890003pjb.101.1589395967883; Wed, 13 May 2020 11:52:47 -0700 (PDT) X-Received: by 2002:a17:90b:957:: with SMTP id dw23mr36889975pjb.101.1589395967645; Wed, 13 May 2020 11:52:47 -0700 (PDT) Received: from localhost ([122.177.166.225]) by smtp.gmail.com with ESMTPSA id h5sm15945895pjv.4.2020.05.13.11.52.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 May 2020 11:52:47 -0700 (PDT) From: Bhupesh Sharma To: linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: bhsharma@redhat.com, bhupesh.linux@gmail.com, James Morse , Mark Rutland , Will Deacon , Steve Capper , Catalin Marinas , Ard Biesheuvel , Dave Anderson , Kazuhito Hagio , linux-kernel@vger.kernel.org, kexec@lists.infradead.org Subject: [PATCH v6 2/2] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo Date: Thu, 14 May 2020 00:22:37 +0530 Message-Id: <1589395957-24628-3-git-send-email-bhsharma@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589395957-24628-1-git-send-email-bhsharma@redhat.com> References: <1589395957-24628-1-git-send-email-bhsharma@redhat.com> 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 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 --- 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 + +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() ? -- 2.7.4