[Crash-utility] [PATCH 1/3] arm64: relax symbol filters
Andrew Jones
drjones at redhat.com
Thu Nov 19 16:33:34 UTC 2015
On Thu, Nov 19, 2015 at 11:18:45AM -0500, Dave Anderson wrote:
>
>
> ----- Original Message -----
> > We need to pass some absolute symbols through, but the highest bit test
> > is filtering all of them out. Remove that, and filter more specifically.
> > ---
> > arm64.c | 4 ++--
> > defs.h | 3 +++
> > 2 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/arm64.c b/arm64.c
> > index 5f8e2f6852434..8cfb863d1bfe2 100644
> > --- a/arm64.c
> > +++ b/arm64.c
> > @@ -305,7 +305,7 @@ arm64_verify_symbol(const char *name, ulong value, char
> > type)
> > if (!name || !strlen(name))
> > return FALSE;
> >
> > - if (((type == 'A') || (type == 'a')) && (highest_bit_long(value) != 63))
> > + if ((type == 'A') && (HAS_SUFFIX(name, ".c") || HAS_SUFFIX(name, ".o")))
> > return FALSE;
> >
> > if ((value == 0) &&
> > @@ -315,7 +315,7 @@ arm64_verify_symbol(const char *name, ulong value, char
> > type)
> > if (STREQ(name, "$d") || STREQ(name, "$x"))
> > return FALSE;
> >
> > - if ((type == 'A') && STRNEQ(name, "__crc_"))
> > + if ((type == 'A') && (STRNEQ(name, "__crc_") || STRNEQ(name,
> > "__reg_num_")))
> > return FALSE;
> >
> > if (!(machdep->flags & KSYMS_START) && STREQ(name, "idmap_pg_dir"))
> > diff --git a/defs.h b/defs.h
> > index 7004619017e41..1bcd1b3b177db 100644
> > --- a/defs.h
> > +++ b/defs.h
> > @@ -155,6 +155,9 @@ static inline int string_exists(char *s) { return (s ?
> > TRUE : FALSE); }
> > (strcmp((char *)(A), (char *)(B)) == 0))
> > #define STRNEQ(A, B) (string_exists((char *)A) && string_exists((char
> > *)B) && \
> > (strncmp((char *)(A), (char *)(B), strlen((char *)(B))) == 0))
> > +#define HAS_SUFFIX(s, suffix) (string_exists((char *)s) &&
> > string_exists((char *)suffix) && \
> > + strlen((char *)s) > strlen((char *)suffix) && \
> > + (strcmp((char *)(s) + strlen((char *)s) - strlen((char *)suffix),
> > (char *)suffix) == 0))
> > #define BZERO(S, N) (memset(S, NULLCHAR, N))
> > #define BCOPY(S, D, C) (memcpy(D, S, C))
> > #define BNEG(S, N) (memset(S, 0xff, N))
> > --
> > 2.4.3
>
>
> Hi Andrew,
>
> Hey, I appreciate the arm/arm64 interest!
>
> Let's start with this patch first...
>
> The "upper-level" symbol table kept by the crash-specific source
> code is only concerned with symbols that are kernel virtual addresses.
> Accordingly, the absolute symbols are stripped, and the ARM64 symbol
> table normally starts like this:
>
> crash> sym -l
> fffffe0000080000 (t) .head.text
> fffffe0000080000 (T) _text
> fffffe0000080000 (t) efi_head
> fffffe0000080040 (t) pe_header
> fffffe0000080044 (t) coff_header
> fffffe0000080058 (t) optional_header
> fffffe0000080070 (t) extra_header_fields
> fffffe00000800f8 (t) section_table
> fffffe0000081000 (T) stext
> fffffe0000081024 (t) preserve_boot_args
> ...
>
> With your patch 1/3 applied, it starts like this:
>
> crash> syms -l
> 0 (A) _kernel_flags_le
> 1 (a) __reg_num_x1
> 1 (a) __reg_num_x1
> 1 (a) __reg_num_x1
> 1 (a) __reg_num_x1
> 1 (a) __reg_num_x1
> 1 (a) __reg_num_x1
> 1 (a) __reg_num_x1
> 2 (a) __reg_num_x2
> 2 (a) __reg_num_x2
> 2 (a) __reg_num_x2
> 2 (a) __reg_num_x2
> 2 (a) __reg_num_x2
> 2 (a) __reg_num_x2
> 2 (a) __reg_num_x2
> 3 (a) __reg_num_x3
> 3 (a) __reg_num_x3
> 3 (a) __reg_num_x3
> 3 (a) __reg_num_x3
> 3 (a) __reg_num_x3
> 3 (a) __reg_num_x3
> 3 (a) __reg_num_x3
> 4 (a) __reg_num_x4
> 4 (a) __reg_num_x4
> 4 (a) __reg_num_x4
> 4 (a) __reg_num_x4
> 4 (a) __reg_num_x4
> 4 (a) __reg_num_x4
> 4 (a) __reg_num_x4
> 5 (a) __reg_num_x5
> 5 (a) __reg_num_x5
> 5 (a) __reg_num_x5
> 5 (a) __reg_num_x5
> 5 (a) __reg_num_x5
> 5 (a) __reg_num_x5
> 5 (a) __reg_num_x5
> 6 (a) __reg_num_x6
> 6 (a) __reg_num_x6
> 6 (a) __reg_num_x6
> 6 (a) __reg_num_x6
> 6 (a) __reg_num_x6
> 6 (a) __reg_num_x6
> 6 (a) __reg_num_x6
> 7 (a) __reg_num_x7
> 7 (a) __reg_num_x7
> 7 (a) __reg_num_x7
> 7 (a) __reg_num_x7
> 7 (a) __reg_num_x7
> 7 (a) __reg_num_x7
> 7 (a) __reg_num_x7
> 8 (a) __reg_num_x8
> 8 (a) __reg_num_x8
> 8 (a) __reg_num_x8
> 8 (a) __reg_num_x8
> 8 (a) __reg_num_x8
> 8 (a) __reg_num_x8
> 8 (a) __reg_num_x8
> 9 (a) __reg_num_x9
> 9 (a) __reg_num_x9
> 9 (a) __reg_num_x9
> 9 (a) __reg_num_x9
> 9 (a) __reg_num_x9
> 9 (a) __reg_num_x9
> 9 (a) __reg_num_x9
> a (a) __reg_num_x10
> a (a) __reg_num_x10
> a (a) __reg_num_x10
> a (a) __reg_num_x10
> a (a) __reg_num_x10
> a (a) __reg_num_x10
> a (a) __reg_num_x10
> b (a) __reg_num_x11
> b (a) __reg_num_x11
> b (a) __reg_num_x11
> b (a) __reg_num_x11
> b (a) __reg_num_x11
> b (a) __reg_num_x11
> b (a) __reg_num_x11
> c (a) __reg_num_x12
> c (a) __reg_num_x12
> c (a) __reg_num_x12
> c (a) __reg_num_x12
> c (a) __reg_num_x12
> c (a) __reg_num_x12
> c (a) __reg_num_x12
> d (a) __reg_num_x13
> d (a) __reg_num_x13
> d (a) __reg_num_x13
> d (a) __reg_num_x13
> d (a) __reg_num_x13
> d (a) __reg_num_x13
> d (a) __reg_num_x13
> e (a) __reg_num_x14
> e (a) __reg_num_x14
> e (a) __reg_num_x14
> e (a) __reg_num_x14
> e (a) __reg_num_x14
> e (a) __reg_num_x14
> e (a) __reg_num_x14
> f (a) __reg_num_x15
> f (a) __reg_num_x15
> f (a) __reg_num_x15
> f (a) __reg_num_x15
> f (a) __reg_num_x15
> f (a) __reg_num_x15
> f (a) __reg_num_x15
> 10 (a) __reg_num_x16
> 10 (a) __reg_num_x16
> 10 (a) __reg_num_x16
> 10 (a) __reg_num_x16
> 10 (a) __reg_num_x16
> 10 (a) __reg_num_x16
> 10 (a) __reg_num_x16
> 11 (a) __reg_num_x17
> 11 (a) __reg_num_x17
> 11 (a) __reg_num_x17
> 11 (a) __reg_num_x17
> 11 (a) __reg_num_x17
> 11 (a) __reg_num_x17
> 11 (a) __reg_num_x17
> 12 (a) __reg_num_x18
> 12 (a) __reg_num_x18
> 12 (a) __reg_num_x18
> 12 (a) __reg_num_x18
> 12 (a) __reg_num_x18
> 12 (a) __reg_num_x18
> 12 (a) __reg_num_x18
> 13 (a) __reg_num_x19
> 13 (a) __reg_num_x19
> 13 (a) __reg_num_x19
> 13 (a) __reg_num_x19
> 13 (a) __reg_num_x19
> 13 (a) __reg_num_x19
> 13 (a) __reg_num_x19
> 14 (a) __reg_num_x20
> 14 (a) __reg_num_x20
> 14 (a) __reg_num_x20
> 14 (a) __reg_num_x20
> 14 (a) __reg_num_x20
> 14 (a) __reg_num_x20
> 14 (a) __reg_num_x20
> 15 (a) __reg_num_x21
> 15 (a) __reg_num_x21
> 15 (a) __reg_num_x21
> 15 (a) __reg_num_x21
> 15 (a) __reg_num_x21
> 15 (a) __reg_num_x21
> 15 (a) __reg_num_x21
> 16 (a) __reg_num_x22
> 16 (a) __reg_num_x22
> 16 (a) __reg_num_x22
> 16 (a) __reg_num_x22
> 16 (a) __reg_num_x22
> 16 (a) __reg_num_x22
> 16 (a) __reg_num_x22
> 17 (a) __reg_num_x23
> 17 (a) __reg_num_x23
> 17 (a) __reg_num_x23
> 17 (a) __reg_num_x23
> 17 (a) __reg_num_x23
> 17 (a) __reg_num_x23
> 17 (a) __reg_num_x23
> 18 (a) __reg_num_x24
> 18 (a) __reg_num_x24
> 18 (a) __reg_num_x24
> 18 (a) __reg_num_x24
> 18 (a) __reg_num_x24
> 18 (a) __reg_num_x24
> 18 (a) __reg_num_x24
> 19 (a) __reg_num_x25
> 19 (a) __reg_num_x25
> 19 (a) __reg_num_x25
> 19 (a) __reg_num_x25
> 19 (a) __reg_num_x25
> 19 (a) __reg_num_x25
> 19 (a) __reg_num_x25
> 1a (a) __reg_num_x26
> 1a (a) __reg_num_x26
> 1a (a) __reg_num_x26
> 1a (a) __reg_num_x26
> 1a (a) __reg_num_x26
> 1a (a) __reg_num_x26
> 1a (a) __reg_num_x26
> 1b (a) __reg_num_x27
> 1b (a) __reg_num_x27
> 1b (a) __reg_num_x27
> 1b (a) __reg_num_x27
> 1b (a) __reg_num_x27
> 1b (a) __reg_num_x27
> 1b (a) __reg_num_x27
> 1c (a) __reg_num_x28
> 1c (a) __reg_num_x28
> 1c (a) __reg_num_x28
> 1c (a) __reg_num_x28
> 1c (a) __reg_num_x28
> 1c (a) __reg_num_x28
> 1c (a) __reg_num_x28
> 1d (a) __reg_num_x29
> 1d (a) __reg_num_x29
> 1d (a) __reg_num_x29
> 1d (a) __reg_num_x29
> 1d (a) __reg_num_x29
> 1d (a) __reg_num_x29
> 1d (a) __reg_num_x29
> 1e (a) __reg_num_x30
> 1e (a) __reg_num_x30
> 1e (a) __reg_num_x30
> 1e (a) __reg_num_x30
> 1e (a) __reg_num_x30
> 1e (a) __reg_num_x30
> 1e (a) __reg_num_x30
> 1f (a) __reg_num_xzr
> 1f (a) __reg_num_xzr
> 1f (a) __reg_num_xzr
> 1f (a) __reg_num_xzr
> 1f (a) __reg_num_xzr
> 1f (a) __reg_num_xzr
> 1f (a) __reg_num_xzr
Oops, I should have checked for type == 'a' when filtering these
__reg_num_* symbols instead of type == 'A' (or both?).
> 200 (A) PECOFF_FILE_ALIGNMENT
> 1000 (A) stext_offset
> 80000 (A) _kernel_offset_le
> 1460000 (A) _kernel_size_le
> fffffe0000080000 (t) .head.text
> fffffe0000080000 (T) _text
> fffffe0000080000 (t) efi_head
> fffffe0000080040 (t) pe_header
> ...
>
> But keeping any absolute symbols below ".head.text" screws things up.
> Say for example, here's a normal "rd -S" call:
>
> crash> rd -S fffffe035a2f6580 100
> fffffe035a2f6580: 0000000000000000 [kmalloc-16384]
> fffffe035a2f6590: 0040410000000002 0000000000000000
> fffffe035a2f65a0: 0000000000000000 0000000000000001
> fffffe035a2f65b0: [task_struct] 0000000000000002
> fffffe035a2f65c0: 000000010c4ac06a 0000000100000000
> fffffe035a2f65d0: 0000007800000078 0000000000000078
> fffffe035a2f65e0: fair_sched_class 0000000000000400
> fffffe035a2f65f0: 0000000000400000 0000000000000001
> fffffe035a2f6600: 0000000000000000 0000000000000000
> fffffe035a2f6610: fffffe03ffec5878 [task_struct]
> fffffe035a2f6620: 0000000000000001 000754096e1781d0
> fffffe035a2f6630: 0000000157d0df88 000000004c7c03e4
> fffffe035a2f6640: 0000000157cffbf4 0000000000000013
> fffffe035a2f6650: 0000000000000001 [kmalloc-192]
> fffffe035a2f6660: [kmalloc-512] 0000000000000000
> fffffe035a2f6670: 000754096e169e3c 0000000000000000
> fffffe035a2f6680: 0000000000000000 0000000000000000
> fffffe035a2f6690: 0000b9f100000026 0000000000000026
> fffffe035a2f66a0: [task_struct] [task_struct]
> fffffe035a2f66b0: 0000000000000000 0000000000000000
> fffffe035a2f66c0: 000000000000000a 0000000000000000
> fffffe035a2f66d0: 0000000000000000 fffffe03ffec5050
> fffffe035a2f66e0: 0000000000000000 [kmalloc-1024]
> fffffe035a2f66f0: [task_struct] 0000000000000000
> fffffe035a2f6700: 0000000000000000 0000000000000000
> fffffe035a2f6710: 0000000000000000 0000000000000000
> fffffe035a2f6720: 0000000000000000 0000000000000000
> fffffe035a2f6730: 0000000000000000 0000000000000000
> fffffe035a2f6740: 0000000000000001 0000000000000000
> fffffe035a2f6750: [task_struct] 0000000000000000
> fffffe035a2f6760: 0000000000000000 0000000000000000
> crash>
>
> With your patch applied, it looks like this:
>
> crash> rd -S fffffe035a2f6580 100
> fffffe035a2f6580: __reg_num_x1 [kmalloc-16384]
> fffffe035a2f6590: _kernel_size_le+18085866743922690 _kernel_flags_le
> fffffe035a2f65a0: _kernel_flags_le _kernel_flags_le
> fffffe035a2f65b0: [task_struct] __reg_num_x3
> fffffe035a2f65c0: _kernel_size_le+4479828301 __reg_num_x1
> fffffe035a2f65d0: _kernel_size_le+515374710904 __reg_num_xzr+89
> fffffe035a2f65e0: fair_sched_class PECOFF_FILE_ALIGNMENT+512
> fffffe035a2f65f0: _kernel_offset_le+3670016 __reg_num_x1
> fffffe035a2f6600: _kernel_flags_le _kernel_flags_le
> fffffe035a2f6610: [task_struct] [task_struct]
> fffffe035a2f6620: _kernel_flags_le _kernel_size_le+2062727142285104
> fffffe035a2f6630: _kernel_size_le+5760795604 _kernel_size_le+1409972385
> fffffe035a2f6640: _kernel_size_le+5760749924 __reg_num_x20
> fffffe035a2f6650: __reg_num_x1 [kmalloc-192]
> fffffe035a2f6660: [kmalloc-512] _kernel_flags_le
> fffffe035a2f6670: _kernel_size_le+2062727142285104 _kernel_size_le+1945805182
> fffffe035a2f6680: _kernel_flags_le _kernel_flags_le
> fffffe035a2f6690: _kernel_size_le+204101119508525 __reg_num_xzr+14
> fffffe035a2f66a0: [task_struct] [task_struct]
> fffffe035a2f66b0: _kernel_flags_le _kernel_flags_le
> fffffe035a2f66c0: __reg_num_x10 _kernel_flags_le
> fffffe035a2f66d0: _kernel_flags_le fffffe03ffee5050
> fffffe035a2f66e0: _kernel_flags_le [kmalloc-1024]
> fffffe035a2f66f0: [task_struct] _kernel_flags_le
> fffffe035a2f6700: _kernel_flags_le _kernel_flags_le
> fffffe035a2f6710: _kernel_flags_le _kernel_flags_le
> fffffe035a2f6720: _kernel_flags_le _kernel_flags_le
> fffffe035a2f6730: _kernel_flags_le _kernel_flags_le
> fffffe035a2f6740: __reg_num_x1 _kernel_flags_le
> fffffe035a2f6750: [task_struct] _kernel_flags_le
> fffffe035a2f6760: _kernel_flags_le _kernel_flags_le
> crash>
Ah, I see. I missed that we'd end up uglifying things with automatic
symbol+offset name outputting.
>
> As I understand it, you're only interested in the "_kernel_flags_le"
> value, so let's just key on that particular absolute symbol in
> arm64_verify_symbol(), and stash it aside for later use.
Sounds good to me. Or, is there a way to flag symbols that we don't
want to use automatically for the nearby addresses? We could then filter
the absolutes we know that we don't want, e.g. __crc_* and __reg_num_*,
but then have a final
if (type == 'A' || type == 'a')
flag_dont_use_symbol_for_nearest_addresses(symbol);
type of thing?
Thanks,
drew
More information about the Crash-utility
mailing list