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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98EA4E77197 for ; Tue, 7 Jan 2025 16:17:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C1D76B00AC; Tue, 7 Jan 2025 11:17:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1726D6B00AD; Tue, 7 Jan 2025 11:17:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05FBD6B00AE; Tue, 7 Jan 2025 11:17:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DD6D46B00AC for ; Tue, 7 Jan 2025 11:17:57 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6ADC8160A90 for ; Tue, 7 Jan 2025 16:17:57 +0000 (UTC) X-FDA: 82981162194.06.63CE4FE Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf25.hostedemail.com (Postfix) with ESMTP id 7A62DA0013 for ; Tue, 7 Jan 2025 16:17:55 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of Dave.Martin@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=Dave.Martin@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736266675; a=rsa-sha256; cv=none; b=PmYSrF9ikwHfVxgrgMdXhg3GoOf+Z1lf0ewQxDmxl7TQ77J+0430LwMd8bs7HTcMWTEEe2 HOCsO1jlqa/dU4L0Aa1o3dJPrjBY7g0g7rFyTFWj5MJj/rmFT0UJxml4j/Ok96YaOgN0hA +uxmtoJrmw2XOPBz3cqWtqxs7SKmYTQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of Dave.Martin@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=Dave.Martin@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736266675; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t8CtES2oYL8C/kvAQfa6mDbgVViASQ+zfjrwizDMYAU=; b=7mUh0r+tTMCc8Nf2XMeMlXWlETM98plZg7YEC0SxuuGWGCtzalsLrJ/S05q794zx1vjGIt G1rnCI46ui/Asy2hksmkvqPAyTEsWe++/BdqTsu3A6aYmj4k7fsle8L0O88CQgJ2uCN7/S MS0XO6sLsh6S48PLiGT1Z/oPdrmsXqQ= 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-Rspamd-Queue-Id: 7A62DA0013 X-Stat-Signature: 3koogwn9bgwi95bk79p3iob7h4ouc4n7 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736266675-549901 X-HE-Meta: U2FsdGVkX196RZt/8bD/H+4TU82vxervE8X51CbA58r3cAu0UqGxBS0YSzGcR9whJ1VjvQYfj1EctHwL7siAMepLIhI8hwKadlR8y3N34A/IpD5C6rJ02d82YO+7F4UtDKEoxlWhoLa8f3pDyUbepQjSeYj0T38oXpfTXdcJ+OTIEr0wOqWc1j4HdqNF1EziT95i+fgxA+ZnlqzEkJ/v1gt6yeXCv3tQmwKsfiNgS1D+O7dw5FJG0ceElTeuUhPZEJD4tSQiggnFTGpT/T+uPj7DhUrgexBEmSo8wMLDmmMxkK3JSsnN0U77TS2vsYY9H2y4o738p20j0iRTvzXvbFOEuEyPVZxA6oS9TzJK62Lnlg0posY4VYh35l3cAIb46Sd3mJpRLFUz8L1Gu+NDL5XbyinMhR9cDgSV7WcVHfZUe9m80EBMAREzU/0HyDAVyu+CgDuNOUz5HUl/4FyKQQK0LlrM05rr7kiR18xBcOUtnILyUoZPB8+tua36NQRgkyav5rfu0Ff3Yaj/51Hegi0Lxl2EZv9PDIK9wvqDbtLGDm2kjoNuONOCwBUrBuh5/sNvaUy18TAr1w64E4/DSd2+YkowR2A3+ubUxXnyy4ABV3SfwXBsCGBZwjeI7ZAY6M29q86Y4QWNFFzGApGV3weSigY8ojHj0XE171QgwjYis2LMvxvWat3rBcABgOO2QpLzNv4LrxPbyeEaSPLA6uGDgt8VgcPDE38aKWBG+ijqps/K7TtFzLP+KwYyeiQcCbjfBw6O+6vgWlG24QP6dnUWhFa9kQlA8Bv1OsSZ6FV3fh9FivrMXrkZDgwfrW9cqAg8C4IN6VIX32LAfcttsrMnK6crHtCcfn14cjXJ6buoscWGLDYNyi5v5cGNCp1MLou5QpAEjGAT63pRhzs93T2ob3TRGtitWKK8On+XB/in7Jojyl5cgTpD/9eIBBhQYST6NjDL8wJDxy89jeO 3tJTDWdL 6ZTuuQk35pN8sFEw6hcCKUZy1D9ErxDrp9XolFRJoxC1OkLv7myUyCYXOw+sKuRwqDG+N8Grehj+Bt04ykO2brhrjuVQ07NMryfsy6LnQ05Fkf+ixFFhAiX2xPX8dRJicaY/M93ryUqOvKpzL+L2TZoVgkpRt5WKmKE89g3P1bdRH7cQlwj4CvXiqu+DYQNNC5nn5yztbdGa0F6o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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