From patchwork Tue Jan 7 12:45:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13928844 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 C1BF5E77197 for ; Tue, 7 Jan 2025 12:48:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 548AB6B00C3; Tue, 7 Jan 2025 07:48:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F7AA6B00C4; Tue, 7 Jan 2025 07:48:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3990D6B00C5; Tue, 7 Jan 2025 07:48:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1A2746B00C3 for ; Tue, 7 Jan 2025 07:48:29 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C5B2E16081E for ; Tue, 7 Jan 2025 12:48:28 +0000 (UTC) X-FDA: 82980634296.15.57CDA3F Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf29.hostedemail.com (Postfix) with ESMTP id D904B12000C for ; Tue, 7 Jan 2025 12:48:26 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=0Y5J5ypN; spf=pass (imf29.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.44 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=1736254106; 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=8B/uoyeuY57p4F5WrCZvdn0Td4esItXL4IJBDCfsGf4=; b=JToZ4r+PQzcehabDEfuLmtP9hgltOVN7T7YwKfq0vkyPXFGywFrx4pWmEP/Q2MAqrG14Ie BYsWbbPkLUqcRKzQCBSGI7kYFM4BuOHmcbmTPJ5RfZMA4xYr1Q8hyrkt9wCVpalkmBBLKz QWuvi27jxebcv3tkJ09iUCij03A6ymE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=0Y5J5ypN; spf=pass (imf29.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736254106; a=rsa-sha256; cv=none; b=aIXPuK9kSavSEVCug55VVFuaRRmRnaDD9LomoVsjL/rHtkRRt0U9Xgad/D1GkfqgF8qetr I2GdDin4Lx1/ivlJ45Dxwwq78RMbx4BC5frI+aWheibEDPyRpPi0LL7lzg6/8FBVQhCIAW HKbm3j3qR4oAyqG3M7vHiU8OFXn6k/o= Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2ee76befe58so22629825a91.2 for ; Tue, 07 Jan 2025 04:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736254105; x=1736858905; 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=8B/uoyeuY57p4F5WrCZvdn0Td4esItXL4IJBDCfsGf4=; b=0Y5J5ypN5Mk9hC5q1LtCgvKDZx3Ua+EiT4F6vYGFhkD6TtOAmmVToqE5gZKZv8U58A hhaYsgojLcLx6g2LDxIcoW6XF/fuOK7jS5C70WsDEKOEycAdSooJZ3HLTxcMnP702Ol8 5+1TRpW7G1R51ASuUJqpOv3jczV3QCo0us8uhYfWxlXn6yFsmwcR1R1ZDMhNXpnO1BLf dlGQXj3T1Q2sAxrhcBLitAcVQFjy3U9adayBCobBegxTnkEwaYmsJ0KSflcCtUrgnMSQ AzjskO4EZS6AIh4XbcpYmHuLxxostu4dPEUzyClSqi3lQ2r7h5Pd/n8XpA2E2vywzWQl jl1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736254105; x=1736858905; 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=8B/uoyeuY57p4F5WrCZvdn0Td4esItXL4IJBDCfsGf4=; b=H2oCIRdJJpfMqlo9m8lO2NzNwkYDkqAYntDOQkRzJyYdtfx/KhItxzKV2tGBvi1oHL 2ighcXALyEpIG/0bDZtbchFHxzJAagd7MrGaLTwqMY3Ed/3T7JF8I8wcqp8sDMzjzKIn p2Us5ci696dt5ghkjG8Cb9gY2BtpH7G8Fao3vWcpp+XQjhw58uETwTe5PPo+j42HGm9w GcL4i24CcGM1lHHTiNWrzgOwqMxUViI0VElnnZXoDjFXQAEE/mVWu33NYEhQ6yn7FTKB lB7qFZ/b24cK7X+K+jOa+Y1+Cmh0tOiM/lDVcrrgU5GgngZ2QD48F6yjIRKCcNGS2Yrp zsAg== X-Gm-Message-State: AOJu0YwuqkDEfyJyALTpsMs+GPByws/F95SWLn0wJtVRHQr/KPCXEQLn B+8bNWt6IVtSEK8ZqsvSbnYX/MfryUPuFtXSVmYtK3k2FFfvB7lsolByL363ayY= X-Gm-Gg: ASbGncsaWaR4/yYiOWPWMzrBSPvLHi9HTwtVL/VK/bP2SGmGZyfbot5Lq8Ngfuvd2nl AQVrgVfYOEG3qo69QaOtl9JnljGHgOYGQjVs0TqBFqbo8sQnimNjSkuJi9dYqhEpGPuZedKTs2f kdJyGOlYv3r/ObDM3SYAIBXoVWK6LUEE9KIQBUNqznPVM9EmdYeshT2Wi5IG/nHx2J7VxJQe2jX jf18ulgE+bEW+yTg4H4ER/quie1eZf4FU/6Fr3/UyeX87EA+eUe2b0gUcA= X-Google-Smtp-Source: AGHT+IFrm4rj/MLEj5on8APad3buiaiqCoLZIEAZ2AeMT04ViEKVqkKOmnPzjy3rlA6C6aSb7vkHeg== X-Received: by 2002:a05:6a00:f96:b0:724:ed8f:4d35 with SMTP id d2e1a72fcca58-72abdedda5fmr91700514b3a.26.1736254105569; Tue, 07 Jan 2025 04:48:25 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-72aad8fd7b0sm22424647b3a.139.2025.01.07.04.48.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2025 04:48:25 -0800 (PST) From: Akihiko Odaki Date: Tue, 07 Jan 2025 21:45:56 +0900 Subject: [PATCH v3 5/6] s390/crash: Use note name macros MIME-Version: 1.0 Message-Id: <20250107-elf-v3-5-99cb505b1ab2@daynix.com> References: <20250107-elf-v3-0-99cb505b1ab2@daynix.com> In-Reply-To: <20250107-elf-v3-0-99cb505b1ab2@daynix.com> To: Eric Biederman , Kees Cook , Catalin Marinas , Mark Brown , Dave Martin , Baoquan He , Vivek Goyal , Dave Young 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 X-Mailer: b4 0.14-dev-fd6e3 X-Rspamd-Server: rspam05 X-Stat-Signature: ku6c645odfng3354fqzfy5zebprwje99 X-Rspamd-Queue-Id: D904B12000C X-Rspam-User: X-HE-Tag: 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ZVln6r2B4oRa7JpD1GF6BgnXsazi1PFjTl+9cmiZoDrOyqzP7NrQV3u/forCPg4BpAUS9zw+oh2+SNfFyuTKd1/bM7juIo5cmip4N0XY1xsrLn9DEfyJDq7D96xTouqveesVJA69PTdnHHnXde4DB3vMBchXTP6Er8tjkec9jeE4mibXyx3R5UufIFvrzx7FZJtnuM18jFkXUNNhHMk83e451hSySA6rFcDBirGbGzzn3A5t0nvSl+uT8AElo0v8BnA/og9W1wAWq286pRnG29yLw== 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..6359ce645756 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 */