From patchwork Sat Jan 11 05:48:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13935792 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 5D91DE7719A for ; Sat, 11 Jan 2025 05:49:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED22A6B0083; Sat, 11 Jan 2025 00:49:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E821A6B0099; Sat, 11 Jan 2025 00:49:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFA326B00A3; Sat, 11 Jan 2025 00:49:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AEBFE6B0083 for ; Sat, 11 Jan 2025 00:49:33 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3895BB0417 for ; Sat, 11 Jan 2025 05:49:33 +0000 (UTC) X-FDA: 82994093826.16.4405C12 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf16.hostedemail.com (Postfix) with ESMTP id 4657F18000A for ; Sat, 11 Jan 2025 05:49:31 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b="NsSG/Cu4"; spf=pass (imf16.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736574571; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2jKrk3bVYPr7k5YkzhCVfFSlyEMyT0et7JHsh9IpwE8=; b=V5ELbrfo0r4BX7ZFA8WJLZvntwcJmlqrP5D31dXoP3P0eCqI9o6NQJ0vjVeCSbAZqGRSdk OoleDY0+L+AFl1zX3ontGkNsBN6D6sm4W62OvP4y4P86Q4qwgc9Ckbdhs+7Hqi9eSG4FTV Rxbw6wGPbnjGTrGrS/Dygq2K6EXyDmE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b="NsSG/Cu4"; spf=pass (imf16.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736574571; a=rsa-sha256; cv=none; b=PdYAOF1WPYuZ5XY62qRWCqmu5dMXMY4Wm9cSztewmHee7F7xr9wHSTuLHQ9XKHWwi1S2vQ L+2jBHiBokfntjFNXAFreJoO1j2Jk+H68qkF83t0Sk8w0Hm5cLtS74OFgsmEowPtKnCoTQ M/KMLxaXhyyLdJ0A63JE/7XJYJVJ+R4= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2164b662090so43418075ad.1 for ; Fri, 10 Jan 2025 21:49:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736574570; x=1737179370; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2jKrk3bVYPr7k5YkzhCVfFSlyEMyT0et7JHsh9IpwE8=; b=NsSG/Cu4mUiK/Yxljt7XnMgvG/xVoyjQ5nR5co5l2y/lVT2jrPQyKFep0tv23srd2N tiSOjLIWZDeZg8SOcFYWn0MNZ2TMiOtBA1FDzz3ZKzksNHsAsaDiYiGNsKZ8DMuJXvGl kTSOhVUPhkPgKHwbNUJDu+Ump64uDy8quK5T9SUkscHnio8QBCBDcvcp4UeVnZOMAVEb FjX+mSNPkmXXqE76QYrw1Jx+WSRPUnVo7YD2Btys6j/QYpv6zXp0s3hVm0RnerKmN8+7 tujv1KGYQYSCg4ptBK/hBW2mcE18poAZWz0RAY89C7JjNjneekaqM2ytv+FoY67VhT4z 9E0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736574570; x=1737179370; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2jKrk3bVYPr7k5YkzhCVfFSlyEMyT0et7JHsh9IpwE8=; b=J14Xqwi556cvm1lSELpzt+IMJBFD60oWHx7+8bNbqbg+xKVPg7wDcsiu1lAIokKorH Bu9zgQBHNiYzgzYWu/2y1hRct/JwVEI7/cTZuSkxOmRaM/7yZv5D1bJW3TgQpRoDmxQf vlXx8MsJUJtLFXdUfpDtMOJ8WZxdUPzRAf3l0nrAcwgdTdhTgiWWpD2BRXB5APppjf2B nN5oluoPmetgpEMd1hT6FudjRQmq4/D7ZtIaAD59P1gXcsaH84KvsfRKuEGpaogT6S70 AuafnrRtrPabYLqIHKw6xToQdRn3qEAPbFTJDSQF+4dztiD0O9Yf3zFz8MIoG3C1/e+J o6Vw== X-Gm-Message-State: AOJu0Yx6PNDC3xs7VeEalw1tUztez9ztSVlNiNRWzuYau/+xIBTiV7/J Mv3W8I3sBYivAerINEkWHpW3dfjsQf+m1HzavjNA2fj3aGEAEDp0hzgGwdfsBEY= X-Gm-Gg: ASbGnctMjFF12K4Swe9ads/QdcE4VGHnBzUr4MzttwkTWMHbi6I2XG4BLW3q4v+BQy8 RMFNkJK1KfEqBZdG0qkk+vsBxHmk4SgUr9bPsJ8cE9zaHpcB9i2rJIMpEL8+KDPur1QYlsOgBke qe18wCyv29Ayakn1VJOW8werei4QOUcPm/jmwHZeHcZZdCN1SXrk/fqwh+XjzHb2+yBxIMfhvch xEP00bqgEs/5Kj/OSg6COKSz3dwEuOwpm7MY3jU8hPRzoGKfuE7rUsvM4Y= X-Google-Smtp-Source: AGHT+IF/DO7Xc25oCNYWji4iMt60P0/C5k2sp2lZQdBF9bk3Ar0+kFGVzpELgHH1uV8P5GY4v7KRrA== X-Received: by 2002:a17:902:e84f:b0:216:410d:4c53 with SMTP id d9443c01a7336-21a83fc6db1mr183636355ad.41.1736574570100; Fri, 10 Jan 2025 21:49:30 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-21a9f217d56sm21372405ad.141.2025.01.10.21.49.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2025 21:49:29 -0800 (PST) From: Akihiko Odaki Date: Sat, 11 Jan 2025 14:48:48 +0900 Subject: [PATCH v4 5/6] s390/crash: Use note name macros MIME-Version: 1.0 Message-Id: <20250111-elf-v4-5-b3841fa0dcd9@daynix.com> References: <20250111-elf-v4-0-b3841fa0dcd9@daynix.com> In-Reply-To: <20250111-elf-v4-0-b3841fa0dcd9@daynix.com> To: Eric Biederman , Kees Cook , Catalin Marinas , Mark Brown , Dave Martin , Baoquan He , Vivek Goyal , Dave Young , LEROY Christophe Cc: 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, Akihiko Odaki , Heiko Carstens X-Mailer: b4 0.14-dev-fd6e3 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4657F18000A X-Rspam-User: X-Stat-Signature: mganr4ahf1dczpzxnuo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LXxPaU0XkuLxaJcnYDW/Ty5b2pdz4e+xNyEyrrZbkBqt4O1I7oJXGj2ZQX7SRNbZPnsa5+lenNTKWvKuVRGRjNkN4iRDTgU0kZgvLl50uXX6zDOs8o2m3VpqadY/ZKIFcO3W1XRksj5NXOUwXIL8S6MsjjC7Itz5mR0fJ6yUouGcIDRFbuEjWs31PJrc9AlGcBZDkec5fpd3tJ22w3VKrg4d1fV91UAYcnFBYrChr9Ez5z03lj8RojksNM8I2mTk+mrb4+bE6zXOq9u7J6NnHmWy2i4bHvQDJ2GW1Tfo6dIEmIh/cEl282EykLefms= 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: Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki Acked-by: Heiko Carstens --- 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 */