Re: [Crash-utility] [PATCH] arm64: fix page size calculation

2018-02-15 Thread Dave Anderson


- Original Message -
> As for v4.16-rc1, crash for arm64 fails to analyze the core dump,
> with a message: cannot determine page size.
> 
> There seems to be a couple of reasons for this:
> [1] splits a 64-bit field of image header, _kernel_flags_le, into two
> 32-bit values and in turn they have got a bit different names.
> 
> [2] and more recent [3] can possibly add extra space between idmap_pg_dir
> and swapper_pg_dir.
> 
> This patch addresses both of changes.
> 
> [1] commit 6ad1fe5d9077 ("arm64: avoid R_AARCH64_ABS64 relocations for
> Image header fields")
> 
> [2] commit 1e1b8c04fa34 ("arm64: entry: Move the trampoline to be before
> PAN")
> 
> [3] commit 4b65a5db3627 ("arm64: Introduce uaccess_{disable,enable}
> functionality based on TTBR0_EL1")
> 
> Signed-off-by: AKASHI Takahiro 


Hi Takahiro,

Thanks for investigating and fixing this -- queued for crash-7.2.2:

  
https://github.com/crash-utility/crash/commit/764e2d09978bb3f87dfaff4c6a59d4a5cc00f277

Dave



> ---
>  arm64.c | 16 ++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/arm64.c b/arm64.c
> index 7904f65..7f87d5b 100644
> --- a/arm64.c
> +++ b/arm64.c
> @@ -172,8 +172,14 @@ arm64_init(int when)
>   if (!machdep->pagesize &&
>   kernel_symbol_exists("swapper_pg_dir") &&
>   kernel_symbol_exists("idmap_pg_dir")) {
> - value = symbol_value("swapper_pg_dir") -
> - symbol_value("idmap_pg_dir");
> + if (kernel_symbol_exists("tramp_pg_dir"))
> + value = symbol_value("tramp_pg_dir");
> + else if (kernel_symbol_exists("reserved_ttbr0"))
> + value = symbol_value("reserved_ttbr0");
> + else
> + value = symbol_value("swapper_pg_dir");
> +
> + value -= symbol_value("idmap_pg_dir");
>   /*
>* idmap_pg_dir is 2 pages prior to 4.1,
>* and 3 pages thereafter.  Only 4K and 64K
> @@ -436,6 +442,12 @@ arm64_verify_symbol(const char *name, ulong value, char
> type)
>   if ((type == 'A') && STREQ(name, "_kernel_flags_le"))
>   machdep->machspec->kernel_flags = le64toh(value);
>  
> + if ((type == 'A') && STREQ(name, "_kernel_flags_le_hi32"))
> + machdep->machspec->kernel_flags |= (le32toh(value) << 32);
> +
> + if ((type == 'A') && STREQ(name, "_kernel_flags_le_lo32"))
> + machdep->machspec->kernel_flags |= le32toh(value);
> +
>   if (((type == 'A') || (type == 'a')) && (highest_bit_long(value) != 63))
>   return FALSE;
>  
> --
> 2.15.1
> 
> --
> Crash-utility mailing list
> Crash-utility@redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
> 

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility


[Crash-utility] [PATCH] arm64: fix page size calculation

2018-02-14 Thread AKASHI Takahiro
As for v4.16-rc1, crash for arm64 fails to analyze the core dump,
with a message: cannot determine page size.

There seems to be a couple of reasons for this:
[1] splits a 64-bit field of image header, _kernel_flags_le, into two
32-bit values and in turn they have got a bit different names.

[2] and more recent [3] can possibly add extra space between idmap_pg_dir
and swapper_pg_dir.

This patch addresses both of changes.

[1] commit 6ad1fe5d9077 ("arm64: avoid R_AARCH64_ABS64 relocations for
Image header fields")

[2] commit 1e1b8c04fa34 ("arm64: entry: Move the trampoline to be before PAN")

[3] commit 4b65a5db3627 ("arm64: Introduce uaccess_{disable,enable}
functionality based on TTBR0_EL1")

Signed-off-by: AKASHI Takahiro 
---
 arm64.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arm64.c b/arm64.c
index 7904f65..7f87d5b 100644
--- a/arm64.c
+++ b/arm64.c
@@ -172,8 +172,14 @@ arm64_init(int when)
if (!machdep->pagesize &&
kernel_symbol_exists("swapper_pg_dir") &&
kernel_symbol_exists("idmap_pg_dir")) {
-   value = symbol_value("swapper_pg_dir") -
-   symbol_value("idmap_pg_dir");
+   if (kernel_symbol_exists("tramp_pg_dir"))
+   value = symbol_value("tramp_pg_dir");
+   else if (kernel_symbol_exists("reserved_ttbr0"))
+   value = symbol_value("reserved_ttbr0");
+   else
+   value = symbol_value("swapper_pg_dir");
+
+   value -= symbol_value("idmap_pg_dir");
/*
 * idmap_pg_dir is 2 pages prior to 4.1,
 * and 3 pages thereafter.  Only 4K and 64K 
@@ -436,6 +442,12 @@ arm64_verify_symbol(const char *name, ulong value, char 
type)
if ((type == 'A') && STREQ(name, "_kernel_flags_le"))
machdep->machspec->kernel_flags = le64toh(value);
 
+   if ((type == 'A') && STREQ(name, "_kernel_flags_le_hi32"))
+   machdep->machspec->kernel_flags |= (le32toh(value) << 32);
+
+   if ((type == 'A') && STREQ(name, "_kernel_flags_le_lo32"))
+   machdep->machspec->kernel_flags |= le32toh(value);
+
if (((type == 'A') || (type == 'a')) && (highest_bit_long(value) != 63))
return FALSE;
 
-- 
2.15.1

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility