From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1F15E77197 for ; Tue, 7 Jan 2025 16:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=t8CtES2oYL8C/kvAQfa6mDbgVViASQ+zfjrwizDMYAU=; b=FRehEXZPXakawpRcxSQ33WoXIC ztRrRyYOHU/birCjYF9yVlmh3MEjvLbEgcKs0WCl9RMcAGn3bgNtF4RBhft/DO5U58pubyTmjiSWY QUbOOouhz9Hc8mBcc9P18KjjTVP3F+4miDEdWiSGWEOAXXbezfuNd6OMNZwzP6Vb26l9t/3ldLeZT 0EPcBw068pHEzbO0qDLIq0RuDX1EQhfZDEyPTlmA2ZNRiasEc9ozK1pDa31xE0X6v/4iYNmGEjA1I 7rldqOPsGzn4RI71Jtd5gn2iarUgApHzAGKyHJZUqC7aznUYLNuc9Am80NWDJ/kpfERp4q65C1fYb KifaSZ6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVCIt-00000005b7w-2OaI; Tue, 07 Jan 2025 16:19:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVCHE-00000005ajT-46mZ for kexec@lists.infradead.org; Tue, 07 Jan 2025 16:17:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 955311424; Tue, 7 Jan 2025 08:18:22 -0800 (PST) Received: from e133380.arm.com (e133380.arm.com [10.1.197.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8FDFC3F59E; Tue, 7 Jan 2025 08:17:52 -0800 (PST) Date: Tue, 7 Jan 2025 16:17:43 +0000 From: Dave Martin To: Akihiko Odaki Cc: Eric Biederman , Kees Cook , Catalin Marinas , Mark Brown , Baoquan He , Vivek Goyal , Dave Young , 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 Subject: Re: [PATCH v3 5/6] s390/crash: Use note name macros Message-ID: References: <20250107-elf-v3-0-99cb505b1ab2@daynix.com> <20250107-elf-v3-5-99cb505b1ab2@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250107-elf-v3-5-99cb505b1ab2@daynix.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_081757_107612_D40C7AAA X-CRM114-Status: GOOD ( 18.01 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org Hi, On Tue, Jan 07, 2025 at 09:45:56PM +0900, Akihiko Odaki wrote: > Use note name macros to match with the userspace's expectation. > > Signed-off-by: Akihiko Odaki > --- > 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 [...] > @@ -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)) Nit: this macro name clashes with the naming scheme in elf.h. I think that there is a (weak) convention that macros with upper-case names don't expand to a C function call; thus, a macro with an upper- case name can be invoked in places where a C function call would not be allowed. (This convention is not followed everywhere, though -- it's up to the maintainer what they prefer here.) (Note also, the outer parentheses and the parentheses around (buf) appear redundant -- although harmless?) > > /* > * 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)) Nit: name prefix clash (again); possibly redundant parentheses. [...] > @@ -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); It might be worth fixing the funny spacing on these lines, since all the affected lines are being replaced. > 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 */ Otherwise, this looks sensible to me. Cheers ---Dave