Skip to contentSkip to conversation

Append new variables to vmcoreinfo (TCR_EL1.T1SZ for arm64 and MAX_PHYSMEM_BITS for all archs)

PATCH RESEND Superseded Bhupesh Sharma 7 participants 24 messages Nov 29, 2019 – Jun 16, 2020

Subsystems (5)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Append new variables to vmcoreinfo (TCR_EL1.T1SZ for arm64 and MAX_PHYSMEM_BITS for all archs)

- Resending the v5 version as Will Deacon reported that the patchset was split into two seperate threads while sending out. It was an issue with my 'msmtp' settings which seems to be now fixed. Please ignore all previous v5 versions.

Changes since v4:
----------------
- v4 can be seen here:
http://lists.infradead.org/pipermail/kexec/2019-November/023961.html
- Addressed comments from Dave and added patches for documenting new variables appended to vmcoreinfo documentation.
- Added testing report shared by Akashi for PATCH 2/5.

Changes since v3:
----------------
- v3 can be seen here:
http://lists.infradead.org/pipermail/kexec/2019-March/022590.html
- Addressed comments from James and exported TCR_EL1.T1SZ in vmcoreinfo instead of PTRS_PER_PGD.
- Added a new patch (via [PATCH 3/3]), which fixes a simple typo in 'Documentation/arm64/memory.rst'

Changes since v2:
----------------
- v2 can be seen here:
http://lists.infradead.org/pipermail/kexec/2019-March/022531.html
- Protected 'MAX_PHYSMEM_BITS' vmcoreinfo variable under CONFIG_SPARSEMEM ifdef sections, as suggested by Kazu.
- Updated vmcoreinfo documentation to add description about 'MAX_PHYSMEM_BITS' variable (via [PATCH 3/3]).

Changes since v1:
----------------
- v1 was sent out as a single patch which can be seen here:
http://lists.infradead.org/pipermail/kexec/2019-February/022411.html

- v2 breaks the single patch into two independent patches:
[PATCH 1/2] appends 'PTRS_PER_PGD' to vmcoreinfo for arm64 arch, whereas [PATCH 2/2] appends 'MAX_PHYSMEM_BITS' to vmcoreinfo in core kernel code (all archs)

This patchset primarily fixes the regression reported in user-space utilities like 'makedumpfile' and 'crash-utility' on arm64 architecture with the availability of 52-bit address space feature in underlying kernel. These regressions have been reported both on CPUs which don't support ARMv8.2 extensions (i.e. LVA, LPA) and are running newer kernels and also on prototype platforms (like ARMv8 FVP simulator model) which support ARMv8.2 extensions and are running newer kernels.

The reason for these regressions is that right now user-space tools have no direct access to these values (since these are not exported from the kernel) and hence need to rely on a best-guess method of determining value of 'vabits_actual' and 'MAX_PHYSMEM_BITS' supported by underlying kernel.

Exporting these values via vmcoreinfo will help user-land in such cases. In addition, 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 arm64 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.

Cc Boris Petkov <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc James Morse <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steve Capper <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Dave Anderson <[email protected]>
Cc Kazuhito Hagio <[email protected]>

Bhupesh Sharma (5):
crash_core, vmcoreinfo: Append 'MAX_PHYSMEM_BITS' to vmcoreinfo arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo Documentation/arm64: Fix a simple typo in memory.rst Documentation/vmcoreinfo: Add documentation for 'MAX_PHYSMEM_BITS' Documentation/vmcoreinfo: Add documentation for 'TCR_EL1.T1SZ'

 Documentation/admin-guide/kdump/vmcoreinfo.rst | 11 +++++++++++
 Documentation/arm64/memory.rst                 |  2 +-
 arch/arm64/include/asm/pgtable-hwdef.h         |  1 +
 arch/arm64/kernel/crash_core.c                 |  9 +++++++++
 kernel/crash_core.c                            |  1 +
 5 files changed, 23 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH RESEND v5 1/5 crash_core, vmcoreinfo: Append 'MAX_PHYSMEM_BITS' to vmcoreinfo

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 <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc James Morse <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steve Capper <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Dave Anderson <[email protected]>
Cc Kazuhito Hagio <[email protected]>
---
 kernel/crash_core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/crash_core.c +1 -0
index 9f1557b98468..18175687133a 100644
@@ -413,6 +413,7 @@ static int __init crash_save_vmcoreinfo_init(void)
 	VMCOREINFO_LENGTH(mem_section, NR_SECTION_ROOTS);
 	VMCOREINFO_STRUCT_SIZE(mem_section);
 	VMCOREINFO_OFFSET(mem_section, section_mem_map);
+	VMCOREINFO_NUMBER(MAX_PHYSMEM_BITS);
 #endif
 	VMCOREINFO_STRUCT_SIZE(page);
 	VMCOREINFO_STRUCT_SIZE(pglist_data);
Signature · 1 line
2.7.4
Tested-by on v5 1/5
#2 lore raw

Re: [RESEND PATCH v5 1/5] crash_core, vmcoreinfo: Append 'MAX_PHYSMEM_BITS' to vmcoreinfo

Quoted 40 lines · Bhupesh Sharma

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://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_bhupesh-2Dsharma_makedumpfile_blob_remove-2Dmax-2Dphys-2Dmem-2Dbit-2Dv1_arch_ppc64.c-23L471&d=DwICAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=t2fPg9D87F7D8jm0_3CG9yoiIKdRg4qc_thBw4bzMhc&m=WdAKu3i_AeChZ2ZngChACvP5LtULN6mgHopxlQbu16Q&s=AYn-OBh6EqC80XVBg3oLc8ivaCwCNs-cm0PMkJ_2fjo&e=

Cc Boris Petkov <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc James Morse <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steve Capper <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Quoted 8 lines
Quoted 17 lines
---
  kernel/crash_core.c | 1 +
  1 file changed, 1 insertion(+)
kernel/crash_core.c +1 -0
index 9f1557b98468..18175687133a 100644
@@ -413,6 +413,7 @@ static int __init crash_save_vmcoreinfo_init(void)
  	VMCOREINFO_LENGTH(mem_section, NR_SECTION_ROOTS);
  	VMCOREINFO_STRUCT_SIZE(mem_section);
  	VMCOREINFO_OFFSET(mem_section, section_mem_map);
+	VMCOREINFO_NUMBER(MAX_PHYSMEM_BITS);
  #endif
  	VMCOREINFO_STRUCT_SIZE(page);
  	VMCOREINFO_STRUCT_SIZE(pglist_data);
Signature · 7 lines
Thank You,
John

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw

PATCH RESEND v5 2/5 arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

In reply to Bhupesh Sharma

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 <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steve Capper <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Dave Anderson <[email protected]>
Cc Kazuhito Hagio <[email protected]>
---
 arch/arm64/include/asm/pgtable-hwdef.h | 1 +
 arch/arm64/kernel/crash_core.c         | 9 +++++++++
 2 files changed, 10 insertions(+)
arch/arm64/include/asm/pgtable-hwdef.h +1 -0
index d9fbd433cc17..d2e7aff5821e 100644
@@ -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)
arch/arm64/kernel/crash_core.c +9 -0
index ca4c3e12d8c5..f78310ba65ea 100644
@@ -7,6 +7,13 @@
 #include <linux/crash_core.h>
 #include <asm/memory.h>
 
+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());
 }
Signature · 1 line
2.7.4
Tested-by on v5 2/5
#4 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Quoted 39 lines · Bhupesh Sharma

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]. https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_pipermail_kexec_2019-2DNovember_023966.html&d=DwICAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=t2fPg9D87F7D8jm0_3CG9yoiIKdRg4qc_thBw4bzMhc&m=hl1GOXoV3jxYFfIKiiUHZCo3tERnHZ8sNFncKCLsu0g&s=AuQKgcRrjZzeOv_rg3saDrjUlJJraGBptzAlDaUNirc&e=
[1]. https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_pipermail_kexec_2019-2DNovember_024006.html&d=DwICAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=t2fPg9D87F7D8jm0_3CG9yoiIKdRg4qc_thBw4bzMhc&m=hl1GOXoV3jxYFfIKiiUHZCo3tERnHZ8sNFncKCLsu0g&s=48CAvsBJrAJIyXWl_7dQd_a4HPt2dYKZ134lP3jDLA8&e=
[2]. https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_pipermail_kexec_2019-2DNovember_023992.html&d=DwICAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=t2fPg9D87F7D8jm0_3CG9yoiIKdRg4qc_thBw4bzMhc&m=hl1GOXoV3jxYFfIKiiUHZCo3tERnHZ8sNFncKCLsu0g&s=c-62ZXf5jXn9NYHIS_Qu6-xlbRjPPyG5D07RoEzVzC4&e=

Quoted 12 lines
Cc James Morse <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steve Capper <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Dave Anderson <[email protected]>
Cc Kazuhito Hagio <[email protected]>
Quoted 44 lines
---
  arch/arm64/include/asm/pgtable-hwdef.h | 1 +
  arch/arm64/kernel/crash_core.c         | 9 +++++++++
  2 files changed, 10 insertions(+)
arch/arm64/include/asm/pgtable-hwdef.h +1 -0
index d9fbd433cc17..d2e7aff5821e 100644
@@ -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)
arch/arm64/kernel/crash_core.c +9 -0
index ca4c3e12d8c5..f78310ba65ea 100644
@@ -7,6 +7,13 @@
  #include <linux/crash_core.h>
  #include <asm/memory.h>
 
+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());
  }
Signature · 7 lines
Thank You,
John

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#5 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

In reply to Bhupesh Sharma

Hi Bhupesh,

Quoted 18 lines · Bhupesh Sharma

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.

Quoted 2 lines

User-space utilities like makedumpfile and crash-utility, need to read/write this value from/to vmcoreinfo

(write?)

Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Quoted 4 lines

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)))

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If user-space tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed and updated. This is a poor argument for adding this to something that ends up as ABI.

I think a better argument is walking the kernel page tables from the core dump. Core code's vmcoreinfo exports the location of the kernel page tables, but in the example above you can't walk them without knowing how T1SZ was configured.

On older kernels, user-space that needs this would have to assume the value it computes from VA_BITs (also in vmcoreinfo) is the value in use.

---%<---

Quoted 11 lines

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

---%<---

This probably belongs in the cover letter instead of the commit log.

(From-memory: one of vmcore/kcore is virtually addressed, the other physically. Does this fix your poblem in both cases?)

arch/arm64/kernel/crash_core.c line 8

Quoted 7 lines
arch/arm64/kernel/crash_core.c +0 -0
index ca4c3e12d8c5..f78310ba65ea 100644
@@ -7,6 +7,13 @@
 #include <linux/crash_core.h>
 #include <asm/memory.h>

You need to include asm/sysreg.h for read_sysreg(), and asm/pgtable-hwdef.h for the macros you added.

arch/arm64/kernel/crash_core.c line 10

Quoted 1 line
arch/arm64/kernel/crash_core.c +1 -0
+static inline u64 get_tcr_el1_t1sz(void);

Why do you need to do this?

arch/arm64/kernel/crash_core.c line 15

Quoted 4 lines
arch/arm64/kernel/crash_core.c +4 -0
+static inline u64 get_tcr_el1_t1sz(void)
+{
+	return (read_sysreg(tcr_el1) & TCR_T1SZ_MASK) >> TCR_T1SZ_OFFSET;
+}

(We don't modify this one, and its always the same one very CPU, so this is fine. This function is only called once when the stringy vmcoreinfo elf_note is created...)

arch/arm64/kernel/crash_core.c void arch_crash_save_vmcoreinfo(void) · line 26

Quoted 9 lines
arch/arm64/kernel/crash_core.c +2 -0
 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());

You document the name as being upper-case.
The two values either values either side are upper-case.

arch/arm64/kernel/crash_core.c void arch_crash_save_vmcoreinfo(void) · line 28

Quoted 2 lines
arch/arm64/kernel/crash_core.c +0 -0
 	vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset());
 }

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi James,

Quoted 21 lines · James Morse

Hi Bhupesh,

Quoted 18 lines · Bhupesh Sharma

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.

Quoted 4 lines
Quoted 2 lines

User-space utilities like makedumpfile and crash-utility, need to read/write this value from/to vmcoreinfo

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can be used for analysis of the root-cause of panic/crash on say an x86_64 host using utilities like crash-utility/gdb.

Quoted 3 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Well that the current user-space utility design, so I am not sure we can tweak that too much.

Quoted 8 lines
Quoted 4 lines

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)))

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If user-space tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed and updated. This is a poor argument for adding this to something that ends up as ABI.

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be used for 'determining' the kernel memory layout.

Quoted 3 lines

I think a better argument is walking the kernel page tables from the core dump. Core code's vmcoreinfo exports the location of the kernel page tables, but in the example above you can't walk them without knowing how T1SZ was configured.

Sure, both makedumpfile and crash-utility (which walks the kernel page tables from the core dump) use this (and similar) information currently in the user-space.

Quoted 2 lines

On older kernels, user-space that needs this would have to assume the value it computes from VA_BITs (also in vmcoreinfo) is the value in use.

Yes, backward compatibility has been handled in the user-space already.

Quoted 9 lines

---%<---

Quoted 8 lines

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]).

Quoted 6 lines
Quoted 3 lines

[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

---%<---

This probably belongs in the cover letter instead of the commit log.

Ok.

Quoted 4 lines

(From-memory: one of vmcore/kcore is virtually addressed, the other physically. Does this fix your poblem in both cases?)

Quoted 10 lines

arch/arm64/kernel/crash_core.c line 8

Quoted 7 lines
arch/arm64/kernel/crash_core.c +0 -0
index ca4c3e12d8c5..f78310ba65ea 100644
@@ -7,6 +7,13 @@
  #include <linux/crash_core.h>
  #include <asm/memory.h>

You need to include asm/sysreg.h for read_sysreg(), and asm/pgtable-hwdef.h for the macros you added.

Ok. Will check as I did not get any compilation errors without the same and build-bot also did not raise a flag for the missing include files.

Quoted 3 lines

arch/arm64/kernel/crash_core.c line 10

Quoted 1 line
arch/arm64/kernel/crash_core.c +1 -0
+static inline u64 get_tcr_el1_t1sz(void);

Why do you need to do this?

Without this I was getting a missing declaration error, while compiling the code.

Quoted 7 lines

arch/arm64/kernel/crash_core.c line 15

Quoted 4 lines
arch/arm64/kernel/crash_core.c +4 -0
+static inline u64 get_tcr_el1_t1sz(void)
+{
+	return (read_sysreg(tcr_el1) & TCR_T1SZ_MASK) >> TCR_T1SZ_OFFSET;
+}

(We don't modify this one, and its always the same one very CPU, so this is fine. This function is only called once when the stringy vmcoreinfo elf_note is created...)

Right.

Quoted 4 lines
Quoted 4 lines
arch/arm64/kernel/crash_core.c +0 -0
  void arch_crash_save_vmcoreinfo(void)
  {
  	VMCOREINFO_NUMBER(VA_BITS);
@@ -15,5 +22,7 @@ void arch_crash_save_vmcoreinfo(void)
Quoted 8 lines

arch/arm64/kernel/crash_core.c void arch_crash_save_vmcoreinfo(void) · line 26

Quoted 5 lines
arch/arm64/kernel/crash_core.c +2 -0
  						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());

You document the name as being upper-case.
The two values either values either side are upper-case.

Ok, will fix this in v6. Thanks for your inputs.

Quoted 2 lines

arch/arm64/kernel/crash_core.c void arch_crash_save_vmcoreinfo(void) · line 28

Quoted 2 lines
arch/arm64/kernel/crash_core.c +0 -0
  	vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset());
  }

Thanks,
Bhupesh

#7 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi Bhupesh,

Quoted 20 lines · Bhupesh Sharma
Quoted 19 lines · James Morse
Quoted 18 lines · Bhupesh Sharma

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.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

User-space utilities like makedumpfile and crash-utility, need to read/write this value from/to vmcoreinfo

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can be used for analysis of the root-cause of panic/crash on say an x86_64 host using utilities like crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Well that the current user-space utility design, so I am not sure we can tweak that too much.

Quoted 3 lines
Quoted 3 lines

The user-space computation for determining whether an address lies in the linear map range is the same as we have in kernel-space:

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

   #define __is_lm_address(addr)    (!(((u64)addr) & BIT(vabits_actual - 1)))

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If user-space tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed and updated. This is a poor argument for adding this to something that ends up as ABI.

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals, like the memory layout we used yesterday. 14c127c957c1 is a case in point.

A debugger trying to rely on this sort of thing would have to play catchup whenever it changes.

I'm looking for a justification that isn't paper-thin. Putting 'for guessing the memory map' in the commit message gives the impression we can support that.

Quoted 6 lines
Quoted 3 lines

I think a better argument is walking the kernel page tables from the core dump. Core code's vmcoreinfo exports the location of the kernel page tables, but in the example above you can't walk them without knowing how T1SZ was configured.

Sure, both makedumpfile and crash-utility (which walks the kernel page tables from the core dump) use this (and similar) information currently in the user-space.

[...]

Quoted 15 lines
Quoted 4 lines

(From-memory: one of vmcore/kcore is virtually addressed, the other physically. Does this fix your poblem in both cases?)

Quoted 10 lines

arch/arm64/kernel/crash_core.c line 8

Quoted 7 lines
arch/arm64/kernel/crash_core.c +0 -0
index ca4c3e12d8c5..f78310ba65ea 100644
@@ -7,6 +7,13 @@
   #include <linux/crash_core.h>
   #include <asm/memory.h>

You need to include asm/sysreg.h for read_sysreg(), and asm/pgtable-hwdef.h for the macros you added.

Quoted 2 lines

Ok. Will check as I did not get any compilation errors without the same and build-bot also did not raise a flag for the missing include files.

Don't trust the header jungle!

Quoted 5 lines
Quoted 3 lines

arch/arm64/kernel/crash_core.c line 10

Quoted 1 line
arch/arm64/kernel/crash_core.c +1 -0
+static inline u64 get_tcr_el1_t1sz(void);

Why do you need to do this?

Without this I was getting a missing declaration error, while compiling the code.

Missing declaration?

Quoted 4 lines
Quoted 4 lines

arch/arm64/kernel/crash_core.c line 15

Quoted 4 lines
arch/arm64/kernel/crash_core.c +4 -0
+static inline u64 get_tcr_el1_t1sz(void)
+{
+    return (read_sysreg(tcr_el1) & TCR_T1SZ_MASK) >> TCR_T1SZ_OFFSET;
+}

Here it is! (I must be going mad...)

Thanks,

James

#8 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

----- Original Message -----

Quoted 62 lines

Hi Bhupesh,

Quoted 23 lines · Bhupesh Sharma
Quoted 22 lines · James Morse
Quoted 20 lines · Bhupesh Sharma

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

Quoted 7 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

Quoted 21 lines
Quoted 4 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Well that the current user-space utility design, so I am not sure we can tweak that too much.

Quoted 6 lines
Quoted 5 lines

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)))

Quoted 6 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

Quoted 6 lines

I disagree. Everything and anything in the kernel will change. The ABI rules apply to stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals, like the memory layout we used yesterday. 14c127c957c1 is a case in point.

A debugger trying to rely on this sort of thing would have to play catchup whenever it changes.

Exactly. That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools. They have always had to "play catchup" precisely because they depend upon kernel internals, which constantly change.

Dave

#9 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi James,

Quoted 37 lines · Dave Anderson

----- Original Message -----

Quoted 35 lines

Hi Bhupesh,

Quoted 23 lines · Bhupesh Sharma
Quoted 22 lines · James Morse
Quoted 20 lines · Bhupesh Sharma

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

Quoted 7 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

That's correct. But for writing to vmcore dump in the kdump kernel, we need to read the symbols from the vmcoreinfo in the primary kernel.

Quoted 29 lines
Quoted 29 lines
Quoted 21 lines
Quoted 4 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Well that the current user-space utility design, so I am not sure we can tweak that too much.

Quoted 6 lines
Quoted 5 lines

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)))
Quoted 6 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals, like the memory layout we used yesterday. 14c127c957c1 is a case in point.

Quoted 8 lines
Quoted 2 lines

A debugger trying to rely on this sort of thing would have to play catchup whenever it changes.

Exactly. That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools. They have always had to "play catchup" precisely because they depend upon kernel internals, which constantly change.

I agree with you and DaveA here. Software user-space debuggers are dependent on kernel internals (which can change from time-to-time) and will have to play catch-up (which has been the case since the very start).

Unfortunately we don't have any clear ABI for software debugging tools - may be something to look for in future.

A case in point is gdb/kgdb, which still needs to run with KASLR turned-off (nokaslr) for debugging, as it confuses gdb which resolve kernel symbol address from symbol table of vmlinux. But we can work-around the same in makedumpfile/crash by reading the 'kaslr_offset' value. And I have several users telling me now they cannot use gdb on KASLR enabled kernel to debug panics, but can makedumpfile + crash combination to achieve the same.

So, we should be looking to fix these utilities which are broken since the 52-bit changes for arm64. Accordingly, I will try to send the v6 soon while incorporating the comments posted on the v5.

Thanks,
Bhupesh

#10 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi Bhupesh,

Quoted 81 lines · Bhupesh Sharma

Hi James,

Quoted 37 lines · Dave Anderson

----- Original Message -----

Quoted 35 lines

Hi Bhupesh,

Quoted 23 lines · Bhupesh Sharma
Quoted 22 lines · James Morse
Quoted 20 lines · Bhupesh Sharma

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

Quoted 7 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

That's correct. But for writing to vmcore dump in the kdump kernel, we need to read the symbols from the vmcoreinfo in the primary kernel.

Quoted 29 lines
Quoted 29 lines
Quoted 21 lines
Quoted 4 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Well that the current user-space utility design, so I am not sure we can tweak that too much.

Quoted 6 lines
Quoted 5 lines

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)))

Quoted 6 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals, like the memory layout we used yesterday. 14c127c957c1 is a case in point.

Quoted 8 lines
Quoted 2 lines

A debugger trying to rely on this sort of thing would have to play catchup whenever it changes.

Exactly.  That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools. They have always had to "play catchup" precisely because they depend upon kernel internals, which constantly change.

Quoted 8 lines

I agree with you and DaveA here. Software user-space debuggers are dependent on kernel internals (which can change from time-to-time) and will have to play catch-up (which has been the case since the very start).

Unfortunately we don't have any clear ABI for software debugging tools - may be something to look for in future.

A case in point is gdb/kgdb, which still needs to run with KASLR turned-off (nokaslr) for debugging, as it confuses gdb which resolve kernel symbol address from symbol table of vmlinux. But we can work-around the same in makedumpfile/crash by reading the 'kaslr_offset' value. And I have several users telling me now they cannot use gdb on KASLR enabled kernel to debug panics, but can makedumpfile + crash combination to achieve the same.

So, we should be looking to fix these utilities which are broken since the 52-bit changes for arm64. Accordingly, I will try to send the v6 soon while incorporating the comments posted on the v5.

Any update on the next v6 version. Since this patch series is fixing the current broken kdump so need this series to add some more fields in vmcoreinfo for Pointer Authentication work.

Thanks,
Amit Daniel

Quoted 12 lines

Thanks,
Bhupesh

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#11 lore raw

Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi Amit,

Quoted 111 lines · Amit Kachhap

Hi Bhupesh,

Quoted 107 lines · Bhupesh Sharma

Hi James,

Quoted 38 lines · Dave Anderson

----- Original Message -----

Quoted 36 lines

Hi Bhupesh,

Quoted 23 lines · Bhupesh Sharma
Quoted 22 lines · James Morse
Quoted 20 lines · Bhupesh Sharma

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

Quoted 8 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can
be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

That's correct. But for writing to vmcore dump in the kdump kernel, we need to read the symbols from the vmcoreinfo in the primary kernel.

Quoted 39 lines
Quoted 35 lines
Quoted 24 lines
Quoted 4 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Well that the current user-space utility design, so I am not sure we can
tweak that too much.

Quoted 7 lines
Quoted 6 lines

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)))
Quoted 7 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If
user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to
stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals,
like the memory layout we used yesterday. 14c127c957c1 is a case in point.

Quoted 3 lines

A debugger trying to rely on this sort of thing would have to play catchup whenever it
changes.

Quoted 7 lines

Exactly. That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools.
They have always had to "play catchup" precisely because they depend upon kernel internals,
which constantly change.

I agree with you and DaveA here. Software user-space debuggers are dependent on kernel internals (which can change from time-to-time) and will have to play catch-up (which has been the case since the very start).

Unfortunately we don't have any clear ABI for software debugging tools - may be something to look for in future.

A case in point is gdb/kgdb, which still needs to run with KASLR turned-off (nokaslr) for debugging, as it confuses gdb which resolve kernel symbol address from symbol table of vmlinux. But we can work-around the same in makedumpfile/crash by reading the 'kaslr_offset' value. And I have several users telling me now they cannot use gdb on KASLR enabled kernel to debug panics, but can makedumpfile + crash combination to achieve the same.

Quoted 7 lines
Quoted 3 lines

So, we should be looking to fix these utilities which are broken since the 52-bit changes for arm64. Accordingly, I will try to send the v6 soon while incorporating the comments posted on the v5.

Any update on the next v6 version. Since this patch series is fixing the current broken kdump so need this series to add some more fields in vmcoreinfo for Pointer Authentication work.

Sorry for the delay. I was caught up in some other urgent arm64 user-space issues.
I am preparing the v6 now and hopefully will be able to post it out for review later today.

Thanks,
Bhupesh

#12 lore raw

Re: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi Bhupesh,

Quoted 104 lines · Bhupesh Sharma

Hi Amit,

Quoted 101 lines · Amit Kachhap

Hi Bhupesh,

Quoted 98 lines · Bhupesh Sharma

Hi James,

Quoted 34 lines · Dave Anderson

----- Original Message -----

Quoted 33 lines

Hi Bhupesh,

Quoted 22 lines · Bhupesh Sharma
Quoted 21 lines · James Morse
Quoted 20 lines · Bhupesh Sharma

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

Quoted 7 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can
be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

That's correct. But for writing to vmcore dump in the kdump kernel, we need to read the symbols from the vmcoreinfo in the primary kernel.

Quoted 33 lines
Quoted 30 lines
Quoted 20 lines
Quoted 3 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know this.

Well that the current user-space utility design, so I am not sure we can
tweak that too much.

Quoted 6 lines
Quoted 6 lines

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)))
Quoted 7 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If
user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to
stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals,
like the memory layout we used yesterday. 14c127c957c1 is a case in point.

Quoted 3 lines

A debugger trying to rely on this sort of thing would have to play catchup whenever it
changes.

Quoted 7 lines

Exactly. That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools.
They have always had to "play catchup" precisely because they depend upon kernel internals,
which constantly change.

I agree with you and DaveA here. Software user-space debuggers are dependent on kernel internals (which can change from time-to-time) and will have to play catch-up (which has been the case since the very start).

Unfortunately we don't have any clear ABI for software debugging tools - may be something to look for in future.

A case in point is gdb/kgdb, which still needs to run with KASLR turned-off (nokaslr) for debugging, as it confuses gdb which resolve kernel symbol address from symbol table of vmlinux. But we can work-around the same in makedumpfile/crash by reading the 'kaslr_offset' value. And I have several users telling me now they cannot use gdb on KASLR enabled kernel to debug panics, but can makedumpfile + crash combination to achieve the same.

So, we should be looking to fix these utilities which are broken since the 52-bit changes for arm64. Accordingly, I will try to send the v6 soon while incorporating the comments posted on the v5.

Quoted 7 lines
Quoted 3 lines

Any update on the next v6 version. Since this patch series is fixing the current broken kdump so need this series to add some more fields in vmcoreinfo for Pointer Authentication work.

Sorry for the delay. I was caught up in some other urgent arm64 user-space issues.
I am preparing the v6 now and hopefully will be able to post it out for review later today.

Did v6 get sent out?

Quoted 5 lines

Thanks,
Bhupesh

Regards,
Scott

#13 lore raw

RE: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hello Bhupesh,
V6 patch set on Linux 5.7, did not help.
I have applied makedump file
http://lists.infradead.org/pipermail/kexec/2019-November/023963.html changes also (makedump-1.6.6). Tried to apply it on makedumpfile 1.6.7. Patch set_2 failed. Would like to know, if you have V5 patch set for makedump file changes. With makedump 1.6.6, able to collect the vmore file.
I used latest crash utility
(https://www.redhat.com/archives/crash-utility/2019-November/msg00014.html
changes are present)
When I used crash utility, following is the error:

Thanks,
-Bharat

-----Original Message-----
From: Scott Branden [mailto:[email protected]]
Sent: Thursday, April 30, 2020 4:34 AM
To: Bhupesh Sharma; Amit Kachhap
Cc: Mark Rutland; [email protected]; Will Deacon; Linux Doc Mailing List; Catalin Marinas; Ard Biesheuvel; kexec mailing list; Linux Kernel Mailing List; Kazuhito Hagio; James Morse; Dave Anderson; bhupesh linux; [email protected]; linux-arm-kernel; Steve Capper; Ray Jui; Bharat Gooty
Subject: Re: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi Bhupesh,

Quoted 112 lines · Bhupesh Sharma

Hi Amit,

Quoted 109 lines · Amit Kachhap

Hi Bhupesh,

Quoted 106 lines · Bhupesh Sharma

Hi James,

Quoted 38 lines · Dave Anderson

----- Original Message -----

Quoted 37 lines

Hi Bhupesh,

Quoted 26 lines · Bhupesh Sharma
Quoted 25 lines · James Morse
Quoted 24 lines · Bhupesh Sharma

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

Quoted 7 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can
be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

That's correct. But for writing to vmcore dump in the kdump kernel, we need to read the symbols from the vmcoreinfo in the primary kernel.

Quoted 36 lines
Quoted 33 lines
Quoted 23 lines
Quoted 4 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know
this.

Well that the current user-space utility design, so I am not sure we can
tweak that too much.

Quoted 7 lines
Quoted 7 lines

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)))
Quoted 8 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If
user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that
ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to
stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals,
like the memory layout we used yesterday. 14c127c957c1 is a case in point.

Quoted 3 lines

A debugger trying to rely on this sort of thing would have to play catchup whenever it
changes.

Quoted 7 lines

Exactly. That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools.
They have always had to "play catchup" precisely because they depend upon kernel internals,
which constantly change.

I agree with you and DaveA here. Software user-space debuggers are dependent on kernel internals (which can change from time-to-time) and will have to play catch-up (which has been the case since the very start).

Unfortunately we don't have any clear ABI for software debugging tools - may be something to look for in future.

A case in point is gdb/kgdb, which still needs to run with KASLR turned-off (nokaslr) for debugging, as it confuses gdb which resolve kernel symbol address from symbol table of vmlinux. But we can work-around the same in makedumpfile/crash by reading the 'kaslr_offset' value. And I have several users telling me now they cannot use gdb on KASLR enabled kernel to debug panics, but can makedumpfile + crash combination to achieve the same.

So, we should be looking to fix these utilities which are broken since the 52-bit changes for arm64. Accordingly, I will try to send the v6 soon while incorporating the comments posted on the v5.

Quoted 7 lines
Quoted 3 lines

Any update on the next v6 version. Since this patch series is fixing the current broken kdump so need this series to add some more fields in vmcoreinfo for Pointer Authentication work.

Sorry for the delay. I was caught up in some other urgent arm64 user-space issues.
I am preparing the v6 now and hopefully will be able to post it out for review later today.

Did v6 get sent out?

Quoted 5 lines

Thanks,
Bhupesh

Regards,
Scott

#14 lore raw

RE: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Sorry, error message was not posted. Following is the error message

crash: cannot determine VA_BITS_ACTUAL

-----Original Message-----
From: Bharat Gooty [mailto:[email protected]]
Sent: Wednesday, June 10, 2020 10:18 PM
To: Scott Branden; 'Bhupesh Sharma'; 'Amit Kachhap'
Cc: 'Mark Rutland'; '[email protected]'; 'Will Deacon'; 'Linux Doc Mailing List'; 'Catalin Marinas'; 'Ard Biesheuvel'; 'kexec mailing list'; 'Linux Kernel Mailing List'; 'Kazuhito Hagio'; 'James Morse'; 'Dave Anderson'; 'bhupesh linux'; '[email protected]'; 'linux-arm-kernel'; 'Steve Capper'; Ray Jui
Subject: RE: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hello Bhupesh,
V6 patch set on Linux 5.7, did not help.
I have applied makedump file
http://lists.infradead.org/pipermail/kexec/2019-November/023963.html changes also (makedump-1.6.6). Tried to apply it on makedumpfile 1.6.7. Patch set_2 failed. Would like to know, if you have V5 patch set for makedump file changes. With makedump 1.6.6, able to collect the vmore file.
I used latest crash utility
(https://www.redhat.com/archives/crash-utility/2019-November/msg00014.html
changes are present)
When I used crash utility, following is the error:

Thanks,
-Bharat

-----Original Message-----
From: Scott Branden [mailto:[email protected]]
Sent: Thursday, April 30, 2020 4:34 AM
To: Bhupesh Sharma; Amit Kachhap
Cc: Mark Rutland; [email protected]; Will Deacon; Linux Doc Mailing List; Catalin Marinas; Ard Biesheuvel; kexec mailing list; Linux Kernel Mailing List; Kazuhito Hagio; James Morse; Dave Anderson; bhupesh linux; [email protected]; linux-arm-kernel; Steve Capper; Ray Jui; Bharat Gooty
Subject: Re: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi Bhupesh,

Quoted 112 lines · Bhupesh Sharma

Hi Amit,

Quoted 109 lines · Amit Kachhap

Hi Bhupesh,

Quoted 106 lines · Bhupesh Sharma

Hi James,

Quoted 38 lines · Dave Anderson

----- Original Message -----

Quoted 37 lines

Hi Bhupesh,

Quoted 26 lines · Bhupesh Sharma
Quoted 25 lines · James Morse
Quoted 24 lines · Bhupesh Sharma

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

Quoted 7 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can
be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

That's correct. But for writing to vmcore dump in the kdump kernel, we need to read the symbols from the vmcoreinfo in the primary kernel.

Quoted 36 lines
Quoted 33 lines
Quoted 23 lines
Quoted 4 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know
this.

Well that the current user-space utility design, so I am not sure we can
tweak that too much.

Quoted 7 lines
Quoted 7 lines

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)))
Quoted 8 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If
user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that
ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to
stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals,
like the memory layout we used yesterday. 14c127c957c1 is a case in point.

Quoted 3 lines

A debugger trying to rely on this sort of thing would have to play catchup whenever it
changes.

Quoted 7 lines

Exactly. That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools.
They have always had to "play catchup" precisely because they depend upon kernel internals,
which constantly change.

I agree with you and DaveA here. Software user-space debuggers are dependent on kernel internals (which can change from time-to-time) and will have to play catch-up (which has been the case since the very start).

Unfortunately we don't have any clear ABI for software debugging tools - may be something to look for in future.

A case in point is gdb/kgdb, which still needs to run with KASLR turned-off (nokaslr) for debugging, as it confuses gdb which resolve kernel symbol address from symbol table of vmlinux. But we can work-around the same in makedumpfile/crash by reading the 'kaslr_offset' value. And I have several users telling me now they cannot use gdb on KASLR enabled kernel to debug panics, but can makedumpfile + crash combination to achieve the same.

So, we should be looking to fix these utilities which are broken since the 52-bit changes for arm64. Accordingly, I will try to send the v6 soon while incorporating the comments posted on the v5.

Quoted 7 lines
Quoted 3 lines

Any update on the next v6 version. Since this patch series is fixing the current broken kdump so need this series to add some more fields in vmcoreinfo for Pointer Authentication work.

Sorry for the delay. I was caught up in some other urgent arm64 user-space issues.
I am preparing the v6 now and hopefully will be able to post it out for review later today.

Did v6 get sent out?

Quoted 5 lines

Thanks,
Bhupesh

Regards,
Scott

#15 lore raw

Re: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

In reply to Bharat Gooty

Hello Bharat,

Quoted 147 lines · Bharat Gooty

Hello Bhupesh,
V6 patch set on Linux 5.7, did not help.
I have applied makedump file
http://lists.infradead.org/pipermail/kexec/2019-November/023963.html changes also (makedump-1.6.6). Tried to apply it on makedumpfile 1.6.7. Patch set_2 failed. Would like to know, if you have V5 patch set for makedump file changes. With makedump 1.6.6, able to collect the vmore file.
I used latest crash utility
(https://www.redhat.com/archives/crash-utility/2019-November/msg00014.html
changes are present)
When I used crash utility, following is the error:

Thanks,
-Bharat

-----Original Message-----
From: Scott Branden [mailto:[email protected]]
Sent: Thursday, April 30, 2020 4:34 AM
To: Bhupesh Sharma; Amit Kachhap
Cc: Mark Rutland; [email protected]; Will Deacon; Linux Doc Mailing List; Catalin Marinas; Ard Biesheuvel; kexec mailing list; Linux Kernel Mailing List; Kazuhito Hagio; James Morse; Dave Anderson; bhupesh linux; [email protected]; linux-arm-kernel; Steve Capper; Ray Jui; Bharat Gooty
Subject: Re: Re: [RESEND PATCH v5 2/5] arm64/crash_core: Export TCR_EL1.T1SZ in vmcoreinfo

Hi Bhupesh,

Quoted 115 lines · Bhupesh Sharma

Hi Amit,

Quoted 112 lines · Amit Kachhap

Hi Bhupesh,

Quoted 103 lines · Bhupesh Sharma

Hi James,

Quoted 38 lines · Dave Anderson

----- Original Message -----

Quoted 37 lines

Hi Bhupesh,

Quoted 26 lines · Bhupesh Sharma
Quoted 25 lines · James Morse
Quoted 24 lines · Bhupesh Sharma

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

Quoted 7 lines
Quoted 1 line

(write?)

Yes, also write so that the vmcoreinfo from an (crashing) arm64 system can
be used for
analysis of the root-cause of panic/crash on say an x86_64 host using utilities like
crash-utility/gdb.

I read this as as "User-space [...] needs to write to vmcoreinfo".

That's correct. But for writing to vmcore dump in the kdump kernel, we need to read the symbols from the vmcoreinfo in the primary kernel.

Quoted 36 lines
Quoted 33 lines
Quoted 23 lines
Quoted 4 lines
Quoted 1 line

for determining if a virtual address lies in the linear map range.

I think this is a fragile example. The debugger shouldn't need to know
this.

Well that the current user-space utility design, so I am not sure we can
tweak that too much.

Quoted 7 lines
Quoted 7 lines

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)))
Quoted 8 lines

This was changed with 14c127c957c1 ("arm64: mm: Flip kernel VA space"). If
user-space
tools rely on 'knowing' the kernel memory layout, they must have to constantly be fixed
and updated. This is a poor argument for adding this to something that
ends up as ABI.

Quoted 3 lines

See above. The user-space has to rely on some ABI/guaranteed hardware-symbols which can be
used for 'determining' the kernel memory layout.

I disagree. Everything and anything in the kernel will change. The ABI rules apply to
stuff exposed via syscalls and kernel filesystems. It does not apply to kernel internals,
like the memory layout we used yesterday. 14c127c957c1 is a case in point.

Quoted 3 lines

A debugger trying to rely on this sort of thing would have to play catchup whenever it
changes.

Quoted 7 lines

Exactly. That's the whole point.

The crash utility and makedumpfile are not in the same league as other user-space tools.
They have always had to "play catchup" precisely because they depend upon kernel internals,
which constantly change.

I agree with you and DaveA here. Software user-space debuggers are dependent on kernel internals (which can change from time-to-time) and will have to play catch-up (which has been the case since the very start).

Unfortunately we don't have any clear ABI for software debugging tools - may be something to look for in future.

A case in point is gdb/kgdb, which still needs to run with KASLR turned-off (nokaslr) for debugging, as it confuses gdb which resolve kernel symbol address from symbol table of vmlinux. But we can work-around the same in makedumpfile/crash by reading the 'kaslr_offset' value. And I have several users telling me now they cannot use gdb on KASLR enabled kernel to debug panics, but can makedumpfile + crash combination to achieve the same.

Quoted 3 lines

So, we should be looking to fix these utilities which are broken since the 52-bit changes for arm64. Accordingly, I will try to send the v6 soon while incorporating the comments posted on the v5.

Any update on the next v6 version. Since this patch series is fixing the current broken kdump so need this series to add some more fields in vmcoreinfo for Pointer Authentication work.

Quoted 6 lines
Quoted 4 lines

Sorry for the delay. I was caught up in some other urgent arm64 user-space issues.
I am preparing the v6 now and hopefully will be able to post it out for review later today.

Did v6 get sent out?

Like I mentioned in a different thread reply, I did not put out the user-space changes just yet, since we are waiting for the kernel patches to be accepted first.

In the last review cycle (v5) we had inconsistencies between the user-space and kernel as user-space utilities like crash accepted the v5 patches while we had to respin the v6 for the kernel side.

But since a few other Red Hat arm partners have asked for the same, please find below my public github trees (with prescribed branches), which you can use for testing the v6 kernel patchset:

1. makedumpfile:
<https://github.com/bhupesh-sharma/makedumpfile/tree/52-bit-va-support-via-vmcore-upstream-v6-rebase>
2. crash-utility:
<https://github.com/bhupesh-sharma/crash/tree/52-bit-va-support-via-vmcore-upstream-v6-rebase>

Hope this helps.

Thanks,
Bhupesh

#16 lore raw

PATCH RESEND v5 3/5 Documentation/arm64: Fix a simple typo in memory.rst

In reply to Bhupesh Sharma

Fix a simple typo in arm64/memory.rst

Cc Jonathan Corbet <[email protected]>
Cc James Morse <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steve Capper <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
---
 Documentation/arm64/memory.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/arm64/memory.rst +1 -1
index 02e02175e6f5..cf03b3290800 100644
@@ -129,7 +129,7 @@ this logic.
 
 As a single binary will need to support both 48-bit and 52-bit VA
 spaces, the VMEMMAP must be sized large enough for 52-bit VAs and
-also must be sized large enought to accommodate a fixed PAGE_OFFSET.
+also must be sized large enough to accommodate a fixed PAGE_OFFSET.
 
 Most code in the kernel should not need to consider the VA_BITS, for
 code that does need to know the VA size the variables are
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#17 lore raw

PATCH RESEND v5 4/5 Documentation/vmcoreinfo: Add documentation for 'MAX_PHYSMEM_BITS'

In reply to Bhupesh Sharma

Add documentation for 'MAX_PHYSMEM_BITS' variable being added to vmcoreinfo.

'MAX_PHYSMEM_BITS' defines the maximum supported physical address space memory.

Cc Boris Petkov <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc James Morse <[email protected]>
Cc Will Deacon <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Dave Anderson <[email protected]>
Cc Kazuhito Hagio <[email protected]>
---
 Documentation/admin-guide/kdump/vmcoreinfo.rst | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/admin-guide/kdump/vmcoreinfo.rst +5 -0
index 007a6b86e0ee..447b64314f56 100644
@@ -93,6 +93,11 @@ It exists in the sparse memory mapping model, and it is also somewhat
 similar to the mem_map variable, both of them are used to translate an
 address.
 
+MAX_PHYSMEM_BITS
+----------------
+
+Defines the maximum supported physical address space memory.
+
 page
 ----
 
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#18 lore raw

PATCH RESEND v5 5/5 Documentation/vmcoreinfo: Add documentation for 'TCR_EL1.T1SZ'

In reply to Bhupesh Sharma

Add documentation for TCR_EL1.T1SZ variable being added to vmcoreinfo.

It indicates the size offset of the memory region addressed by TTBR1_EL1 and hence can be used for determining the vabits_actual value.

Cc James Morse <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Will Deacon <[email protected]>
Cc Steve Capper <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Dave Anderson <[email protected]>
Cc Kazuhito Hagio <[email protected]>
---
 Documentation/admin-guide/kdump/vmcoreinfo.rst | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/admin-guide/kdump/vmcoreinfo.rst +6 -0
index 447b64314f56..f9349f9d3345 100644
@@ -398,6 +398,12 @@ KERNELOFFSET
 The kernel randomization offset. Used to compute the page offset. If
 KASLR is disabled, this value is zero.
 
+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.
+
 arm
 ===
 
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#19 lore raw

Re: [RESEND PATCH v5 5/5] Documentation/vmcoreinfo: Add documentation for 'TCR_EL1.T1SZ'

Hi Bhupesh,

Quoted 6 lines · Bhupesh Sharma

Add documentation for TCR_EL1.T1SZ variable being added to vmcoreinfo.

It indicates the size offset of the memory region addressed by TTBR1_EL1

and hence can be used for determining the vabits_actual value.

used for determining random-internal-kernel-variable, that might not exist tomorrow.

Could you describe how this is useful/necessary if a debugger wants to walk the page tables from the core file? I think this is a better argument.

Wouldn't the documentation be better as part of the patch that adds the export? (... unless these have to go via different trees? ..)

Quoted 5 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +0 -0
index 447b64314f56..f9349f9d3345 100644

Documentation/admin-guide/kdump/vmcoreinfo.rst KERNELOFFSET · line 406

Quoted 9 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +5 -0
@@ -398,6 +398,12 @@ KERNELOFFSET
 The kernel randomization offset. Used to compute the page offset. If
 KASLR is disabled, this value is zero.
 
+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.

'vabits_actual' may not exist when the next person comes to read this documentation (its going to rot really quickly).

I think the first half of this text is enough to say what this is for. You should include words to the effect that its the hardware value that goes with swapper_pg_dir. You may want to point readers to the arm-arm for more details on what the value means.

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#20 lore raw

Re: [RESEND PATCH v5 5/5] Documentation/vmcoreinfo: Add documentation for 'TCR_EL1.T1SZ'

Hi James,

Quoted 1 line · James Morse

Hi Bhupesh,

I am sorry this review mail skipped my attention due to holidays and focus on other urgent issues.

Quoted 8 lines · Bhupesh Sharma
Quoted 6 lines

Add documentation for TCR_EL1.T1SZ variable being added to vmcoreinfo.

It indicates the size offset of the memory region addressed by TTBR1_EL1

and hence can be used for determining the vabits_actual value.

Quoted 7 lines

used for determining random-internal-kernel-variable, that might not exist tomorrow.

Could you describe how this is useful/necessary if a debugger wants to walk the page tables from the core file? I think this is a better argument.

Wouldn't the documentation be better as part of the patch that adds the export? (... unless these have to go via different trees? ..)

Ok, will fix the same in v6 version.

Quoted 13 lines
Quoted 12 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +4 -0
index 447b64314f56..f9349f9d3345 100644
@@ -398,6 +398,12 @@ KERNELOFFSET
  The kernel randomization offset. Used to compute the page offset. If
  KASLR is disabled, this value is zero.
 
+TCR_EL1.T1SZ
+------------
+
+Indicates the size offset of the memory region addressed by TTBR1_EL1
Quoted 8 lines

Documentation/admin-guide/kdump/vmcoreinfo.rst KERNELOFFSET · line 405

Quoted 1 line
Documentation/admin-guide/kdump/vmcoreinfo.rst +1 -0
+and hence can be used for determining the vabits_actual value.

'vabits_actual' may not exist when the next person comes to read this documentation (its going to rot really quickly).

I think the first half of this text is enough to say what this is for. You should include words to the effect that its the hardware value that goes with swapper_pg_dir. You may want to point readers to the arm-arm for more details on what the value means.

Ok, got it. Fixed this in v6, which should be on its way shortly.

Thanks,
Bhupesh

#21 lore raw

Re: Re: [RESEND PATCH v5 5/5] Documentation/vmcoreinfo: Add documentation for 'TCR_EL1.T1SZ'

Hi Bhupesh,

Would be great to get this patch series upstreamed?

Quoted 39 lines · Bhupesh Sharma

Hi James,

Quoted 1 line · James Morse

Hi Bhupesh,

I am sorry this review mail skipped my attention due to holidays and focus on other urgent issues.

Quoted 8 lines · Bhupesh Sharma
Quoted 6 lines

Add documentation for TCR_EL1.T1SZ variable being added to vmcoreinfo.

It indicates the size offset of the memory region addressed by TTBR1_EL1

and hence can be used for determining the vabits_actual value.

Quoted 7 lines

used for determining random-internal-kernel-variable, that might not exist tomorrow.

Could you describe how this is useful/necessary if a debugger wants to walk the page tables from the core file? I think this is a better argument.

Wouldn't the documentation be better as part of the patch that adds the export? (... unless these have to go via different trees? ..)

Ok, will fix the same in v6 version.

Quoted 14 lines
Quoted 13 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +0 -0
index 447b64314f56..f9349f9d3345 100644
@@ -398,6 +398,12 @@ KERNELOFFSET

  The kernel randomization offset. Used to compute the page offset. If KASLR is disabled, this value is zero.
  +TCR_EL1.T1SZ
+------------

Documentation/admin-guide/kdump/vmcoreinfo.rst +3 -0
+
+Indicates the size offset of the memory region addressed by TTBR1_EL1
 
+and hence can be used for determining the vabits_actual value.
Quoted 8 lines
Quoted 6 lines

'vabits_actual' may not exist when the next person comes to read this documentation (its going to rot really quickly).

I think the first half of this text is enough to say what this is for. You should include words to the effect that its the hardware value that goes with swapper_pg_dir. You may want to point readers to the arm-arm for more details on what the value means.

Ok, got it. Fixed this in v6, which should be on its way shortly.

I can't seem to find v6?

Quoted 10 lines

Thanks,
Bhupesh

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#22 lore raw

Re: Re: [RESEND PATCH v5 5/5] Documentation/vmcoreinfo: Add documentation for 'TCR_EL1.T1SZ'

Hello Scott,

Quoted 62 lines · Scott Branden

Hi Bhupesh,

Would be great to get this patch series upstreamed?

Quoted 56 lines · Bhupesh Sharma

Hi James,

Quoted 1 line · James Morse

Hi Bhupesh,

I am sorry this review mail skipped my attention due to holidays and focus on other urgent issues.

Quoted 12 lines · Bhupesh Sharma
Quoted 7 lines

Add documentation for TCR_EL1.T1SZ variable being added to vmcoreinfo.

It indicates the size offset of the memory region addressed by TTBR1_EL1

and hence can be used for determining the vabits_actual value.

used for determining random-internal-kernel-variable, that might not exist tomorrow.

Quoted 7 lines

Could you describe how this is useful/necessary if a debugger wants to walk the page
tables from the core file? I think this is a better argument.

Wouldn't the documentation be better as part of the patch that adds the export?
(... unless these have to go via different trees? ..)

Ok, will fix the same in v6 version.

Quoted 25 lines
Quoted 6 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +0 -0
index 447b64314f56..f9349f9d3345 100644

Documentation/admin-guide/kdump/vmcoreinfo.rst KERNELOFFSET · line 405

Quoted 8 lines
Documentation/admin-guide/kdump/vmcoreinfo.rst +4 -0
@@ -398,6 +398,12 @@ KERNELOFFSET
  The kernel randomization offset. Used to compute the page offset. If
  KASLR is disabled, this value is zero.
  +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.

'vabits_actual' may not exist when the next person comes to read this documentation (its
going to rot really quickly).

I think the first half of this text is enough to say what this is for. You should include
words to the effect that its the hardware value that goes with swapper_pg_dir. You may
want to point readers to the arm-arm for more details on what the value means.

Quoted 2 lines
Quoted 1 line

Ok, got it. Fixed this in v6, which should be on its way shortly.

I can't seem to find v6?

Oops. I remember Cc'ing you to the v6 patchset (may be my email client messed up), anyways here is the v6 patchset for your reference:
<http://lists.infradead.org/pipermail/kexec/2020-May/025095.html>

Do share your review/test comments on the same.

Thanks,
Bhupesh

#23 lore raw

Re: Re: [RESEND PATCH v5 5/5] Documentation/vmcoreinfo: Add documentation for 'TCR_EL1.T1SZ'

Hi Bhupesh,

Quoted 19 lines · Bhupesh Sharma

Hello Scott,

Quoted 14 lines · Scott Branden

Hi Bhupesh,

Would be great to get this patch series upstreamed?

Quoted 8 lines · Bhupesh Sharma

Hi James,

Quoted 1 line · James Morse

Hi Bhupesh,

I am sorry this review mail skipped my attention due to holidays and focus on other urgent issues.

<SNIP>

Quoted 10 lines
Quoted 3 lines
Quoted 2 lines

Ok, got it. Fixed this in v6, which should be on its way shortly.

I can't seem to find v6?

Oops. I remember Cc'ing you to the v6 patchset (may be my email client messed up), anyways here is the v6 patchset for your reference:
<http://lists.infradead.org/pipermail/kexec/2020-May/025095.html>

Do share your review/test comments on the same.

I found the cover letter but didn't get the patches. Thanks for sending link.
v5 worked fine for us. Will get someone to try out v6 and let you know.

Quoted 5 lines

Thanks,
Bhupesh

Regards,

Scott