Re: [PATCH] arm64: deduce the start address of kernel code, based on kernel version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Pingfan,

thanks for the patch.

-----Original Message-----
> After kernel commit e2a073dde921 ("arm64: omit [_text, _stext) from
> permanent kernel mapping"), the range [_text, _stext] is reclaimed. But
> the current crash code still assumes kernel starting from "_text".
> 
> This change only affects the vmalloced area on arm64 and may result a
> false in arm64_IS_VMALLOC_ADDR().
> 
> Since vmcore has no extra information about this trival change, it can
> only be deduced from kernel version, which means ms->kimage_text can not
> be correctly initialized until kernel_init() finishes. This is fine
> since there is no access to vmalloced area at this early stage.
> 
> Signed-off-by: Pingfan Liu <piliu@xxxxxxxxxx>
> ---
>  arm64.c  | 17 +++++++++++++++++
>  defs.h   |  1 +
>  kernel.c |  3 +++
>  3 files changed, 21 insertions(+)
> 
> diff --git a/arm64.c b/arm64.c
> index 4f2c2b5..4aa971c 100644
> --- a/arm64.c
> +++ b/arm64.c
> @@ -92,6 +92,21 @@ static void arm64_calc_VA_BITS(void);
>  static int arm64_is_uvaddr(ulong, struct task_context *);
>  static void arm64_calc_KERNELPACMASK(void);
> 
> +/* called by kernel_init() */
> +static void arm64_post_kernel_init(void)
> +{
> +	struct machine_specific *ms = machdep->machspec;
> +	struct syment *sp;
> +
> +	if (THIS_KERNEL_VERSION >= LINUX(5,11,0))
> +		sp = kernel_symbol_search("_stext");
> +	else
> +		sp = kernel_symbol_search("_text");
> +
> +	ms->kimage_text = (sp ? sp->value : 0);
> +	sp = kernel_symbol_search("_end");
> +	ms->kimage_end = (sp ? sp->value : 0);
> +}
> 
>  /*
>   * Do all necessary machine-specific setup here. This is called several times
> @@ -104,6 +119,7 @@ arm64_init(int when)
>  	char *string;
>  	struct machine_specific *ms;
> 
> +	arch_post_kernel_init = arm64_post_kernel_init;

Why is the arch_post_kernel_init needed, i.e. can't we put it in
machdep_init(POST_GDB)?

Thanks,
Kazu

>  #if defined(__x86_64__)
>  	if (ACTIVE())
>  		error(FATAL, "compiled for the ARM64 architecture\n");
> @@ -241,6 +257,7 @@ arm64_init(int when)
>  		if (machdep->flags & NEW_VMEMMAP) {
>  			struct syment *sp;
> 
> +			/* It is finally decided in arm64_post_kernel_init() */
>  			sp = kernel_symbol_search("_text");
>  			ms->kimage_text = (sp ? sp->value : 0);
>  			sp = kernel_symbol_search("_end");
> diff --git a/defs.h b/defs.h
> index 7d386d2..04ab55a 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -5677,6 +5677,7 @@ struct command_table_entry *crash_cmd_table(void);
>  /*
>   *  kernel.c
>   */
> +extern void (*arch_post_kernel_init)(void);
>  void kernel_init(void);
>  void module_init(void);
>  void verify_version(void);
> diff --git a/kernel.c b/kernel.c
> index 9c4aabf..b64ffac 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -98,6 +98,7 @@ static char *vmcoreinfo_read_string(const char *);
>  static void check_vmcoreinfo(void);
>  static int is_pvops_xen(void);
> 
> +void (*arch_post_kernel_init)(void);
> 
>  /*
>   *  Gather a few kernel basics.
> @@ -823,6 +824,8 @@ kernel_init()
>  		source_tree_init();
> 
>  	kt->flags &= ~PRE_KERNEL_INIT;
> +	if (arch_post_kernel_init)
> +		arch_post_kernel_init();
>  }
> 
>  /*
> --
> 2.31.1
> 
> --
> Crash-utility mailing list
> Crash-utility@xxxxxxxxxx
> https://listman.redhat.com/mailman/listinfo/crash-utility


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




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux