linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Martin <Dave.Martin@arm.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: Eric Biederman <ebiederm@xmission.com>,
	Kees Cook <kees@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Mark Brown <broonie@kernel.org>, Baoquan He <bhe@redhat.com>,
	Vivek Goyal <vgoyal@redhat.com>, Dave Young <dyoung@redhat.com>,
	LEROY Christophe <christophe.leroy2@cs-soprasteria.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
	kexec@lists.infradead.org, binutils@sourceware.org,
	devel@daynix.com, Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH v4 5/6] s390/crash: Use note name macros
Date: Tue, 14 Jan 2025 12:23:26 +0000	[thread overview]
Message-ID: <Z4ZXPp76UiLtBCLA@e133380.arm.com> (raw)
In-Reply-To: <20250111-elf-v4-5-b3841fa0dcd9@daynix.com>

Hi,

On Sat, Jan 11, 2025 at 02:48:48PM +0900, Akihiko Odaki wrote:
> Use note name macros to match with the userspace's expectation.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com>

Reviewed-by: Dave Martin <Dave.Martin@arm.com>

(I'm not in a position to test this, though.)

> ---
>  arch/s390/kernel/crash_dump.c | 62 ++++++++++++++++---------------------------
>  1 file changed, 23 insertions(+), 39 deletions(-)
> 
> diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c
> index cd0c93a8fb8b..022f4f198edf 100644
> --- a/arch/s390/kernel/crash_dump.c
> +++ b/arch/s390/kernel/crash_dump.c
> @@ -248,15 +248,6 @@ bool is_kdump_kernel(void)
>  }
>  EXPORT_SYMBOL_GPL(is_kdump_kernel);
>  
> -static const char *nt_name(Elf64_Word type)
> -{
> -	const char *name = "LINUX";
> -
> -	if (type == NT_PRPSINFO || type == NT_PRSTATUS || type == NT_PRFPREG)
> -		name = KEXEC_CORE_NOTE_NAME;
> -	return name;
> -}
> -
>  /*
>   * Initialize ELF note
>   */
> @@ -281,10 +272,8 @@ static void *nt_init_name(void *buf, Elf64_Word type, void *desc, int d_len,
>  	return PTR_ADD(buf, len);
>  }
>  
> -static inline void *nt_init(void *buf, Elf64_Word type, void *desc, int d_len)
> -{
> -	return nt_init_name(buf, type, desc, d_len, nt_name(type));
> -}
> +#define nt_init(buf, type, desc) \
> +	nt_init_name(buf, NT_ ## type, &(desc), sizeof(desc), NN_ ## type)
>  
>  /*
>   * Calculate the size of ELF note
> @@ -300,10 +289,7 @@ static size_t nt_size_name(int d_len, const char *name)
>  	return size;
>  }
>  
> -static inline size_t nt_size(Elf64_Word type, int d_len)
> -{
> -	return nt_size_name(d_len, nt_name(type));
> -}
> +#define nt_size(type, desc) nt_size_name(sizeof(desc), NN_ ## type)
>  
>  /*
>   * Fill ELF notes for one CPU with save area registers
> @@ -324,18 +310,16 @@ static void *fill_cpu_elf_notes(void *ptr, int cpu, struct save_area *sa)
>  	memcpy(&nt_fpregset.fpc, &sa->fpc, sizeof(sa->fpc));
>  	memcpy(&nt_fpregset.fprs, &sa->fprs, sizeof(sa->fprs));
>  	/* Create ELF notes for the CPU */
> -	ptr = nt_init(ptr, NT_PRSTATUS, &nt_prstatus, sizeof(nt_prstatus));
> -	ptr = nt_init(ptr, NT_PRFPREG, &nt_fpregset, sizeof(nt_fpregset));
> -	ptr = nt_init(ptr, NT_S390_TIMER, &sa->timer, sizeof(sa->timer));
> -	ptr = nt_init(ptr, NT_S390_TODCMP, &sa->todcmp, sizeof(sa->todcmp));
> -	ptr = nt_init(ptr, NT_S390_TODPREG, &sa->todpreg, sizeof(sa->todpreg));
> -	ptr = nt_init(ptr, NT_S390_CTRS, &sa->ctrs, sizeof(sa->ctrs));
> -	ptr = nt_init(ptr, NT_S390_PREFIX, &sa->prefix, sizeof(sa->prefix));
> +	ptr = nt_init(ptr, PRSTATUS, nt_prstatus);
> +	ptr = nt_init(ptr, PRFPREG, nt_fpregset);
> +	ptr = nt_init(ptr, S390_TIMER, sa->timer);
> +	ptr = nt_init(ptr, S390_TODCMP, sa->todcmp);
> +	ptr = nt_init(ptr, S390_TODPREG, sa->todpreg);
> +	ptr = nt_init(ptr, S390_CTRS, sa->ctrs);
> +	ptr = nt_init(ptr, S390_PREFIX, sa->prefix);
>  	if (cpu_has_vx()) {
> -		ptr = nt_init(ptr, NT_S390_VXRS_HIGH,
> -			      &sa->vxrs_high, sizeof(sa->vxrs_high));
> -		ptr = nt_init(ptr, NT_S390_VXRS_LOW,
> -			      &sa->vxrs_low, sizeof(sa->vxrs_low));
> +		ptr = nt_init(ptr, S390_VXRS_HIGH, sa->vxrs_high);
> +		ptr = nt_init(ptr, S390_VXRS_LOW, sa->vxrs_low);
>  	}
>  	return ptr;
>  }
> @@ -348,16 +332,16 @@ static size_t get_cpu_elf_notes_size(void)
>  	struct save_area *sa = NULL;
>  	size_t size;
>  
> -	size =	nt_size(NT_PRSTATUS, sizeof(struct elf_prstatus));
> -	size +=  nt_size(NT_PRFPREG, sizeof(elf_fpregset_t));
> -	size +=  nt_size(NT_S390_TIMER, sizeof(sa->timer));
> -	size +=  nt_size(NT_S390_TODCMP, sizeof(sa->todcmp));
> -	size +=  nt_size(NT_S390_TODPREG, sizeof(sa->todpreg));
> -	size +=  nt_size(NT_S390_CTRS, sizeof(sa->ctrs));
> -	size +=  nt_size(NT_S390_PREFIX, sizeof(sa->prefix));
> +	size =	nt_size(PRSTATUS, struct elf_prstatus);
> +	size += nt_size(PRFPREG, elf_fpregset_t);
> +	size += nt_size(S390_TIMER, sa->timer);
> +	size += nt_size(S390_TODCMP, sa->todcmp);
> +	size += nt_size(S390_TODPREG, sa->todpreg);
> +	size += nt_size(S390_CTRS, sa->ctrs);
> +	size += nt_size(S390_PREFIX, sa->prefix);
>  	if (cpu_has_vx()) {
> -		size += nt_size(NT_S390_VXRS_HIGH, sizeof(sa->vxrs_high));
> -		size += nt_size(NT_S390_VXRS_LOW, sizeof(sa->vxrs_low));
> +		size += nt_size(S390_VXRS_HIGH, sa->vxrs_high);
> +		size += nt_size(S390_VXRS_LOW, sa->vxrs_low);
>  	}
>  
>  	return size;
> @@ -373,7 +357,7 @@ static void *nt_prpsinfo(void *ptr)
>  	memset(&prpsinfo, 0, sizeof(prpsinfo));
>  	prpsinfo.pr_sname = 'R';
>  	strcpy(prpsinfo.pr_fname, "vmlinux");
> -	return nt_init(ptr, NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo));
> +	return nt_init(ptr, PRPSINFO, prpsinfo);
>  }
>  
>  /*
> @@ -589,7 +573,7 @@ static size_t get_elfcorehdr_size(int phdr_count)
>  	/* PT_NOTES */
>  	size += sizeof(Elf64_Phdr);
>  	/* nt_prpsinfo */
> -	size += nt_size(NT_PRPSINFO, sizeof(struct elf_prpsinfo));
> +	size += nt_size(PRPSINFO, struct elf_prpsinfo);
>  	/* regsets */
>  	size += get_cpu_cnt() * get_cpu_elf_notes_size();
>  	/* nt_vmcoreinfo */
> 
> -- 
> 2.47.1
> 
> 


  reply	other threads:[~2025-01-14 12:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-11  5:48 [PATCH v4 0/6] elf: Define " Akihiko Odaki
2025-01-11  5:48 ` [PATCH v4 1/6] " Akihiko Odaki
2025-01-14 12:22   ` Dave Martin
2025-01-11  5:48 ` [PATCH v4 2/6] binfmt_elf: Use " Akihiko Odaki
2025-01-14 12:22   ` Dave Martin
2025-01-11  5:48 ` [PATCH v4 3/6] powerpc: " Akihiko Odaki
2025-01-14 12:23   ` Dave Martin
2025-01-11  5:48 ` [PATCH v4 4/6] crash: " Akihiko Odaki
2025-01-14 12:23   ` Dave Martin
2025-01-11  5:48 ` [PATCH v4 5/6] s390/crash: " Akihiko Odaki
2025-01-14 12:23   ` Dave Martin [this message]
2025-01-11  5:48 ` [PATCH v4 6/6] crash: Remove KEXEC_CORE_NOTE_NAME Akihiko Odaki
2025-01-14 12:23   ` Dave Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z4ZXPp76UiLtBCLA@e133380.arm.com \
    --to=dave.martin@arm.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=bhe@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=christophe.leroy2@cs-soprasteria.com \
    --cc=devel@daynix.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=hca@linux.ibm.com \
    --cc=kees@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox