From patchwork Wed Jan 15 05:48:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13939853 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 CDE49C02183 for ; Wed, 15 Jan 2025 05:49:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 654E9280007; Wed, 15 Jan 2025 00:49:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60522280005; Wed, 15 Jan 2025 00:49:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A602280007; Wed, 15 Jan 2025 00:49:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2B76B280005 for ; Wed, 15 Jan 2025 00:49:14 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DCBADA0614 for ; Wed, 15 Jan 2025 05:49:13 +0000 (UTC) X-FDA: 83008608186.23.D2E1992 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf15.hostedemail.com (Postfix) with ESMTP id 07BE1A0009 for ; Wed, 15 Jan 2025 05:49:11 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=qK+TNaAg; dmarc=none; spf=pass (imf15.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736920152; a=rsa-sha256; cv=none; b=fBiN4Q0wRM9Uf80I12xzMgJCoO9m09Lm4BRdxcFlUQehH8WHE45ymFVzTShE2uu36GGjpc ZQqoa1mNvuehpSKDLD0CJej4bxnjEQHXZFi3VmJdq0fhAbtpwp9odDUeoEQIlt/zdNr+/S U2ZMQghV0eRhSFTM37RkGEuUQs7V6vU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=qK+TNaAg; dmarc=none; spf=pass (imf15.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736920152; 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=gqxfn2Bh8pqSgpWAhYuCaH8o2BUeXgVOaRACTrcmMAY=; b=YuR6liLqWUBNm7E9G2W3E3IjmvjHRenzb6SX0VsrA/dXm7Dg1Gx6nocLC4UBbJY2IgWYS1 xLMyAGtSscTNKevGY77VNzBYOSy6pSrwxgYnsl/Sx+TQPIzeWTsPNQa0vjAYELj/ktihOs mmWhi4/ImVIRSa7+lchdeUPkxPNJtBM= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-21670dce0a7so137017485ad.1 for ; Tue, 14 Jan 2025 21:49:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736920151; x=1737524951; 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=gqxfn2Bh8pqSgpWAhYuCaH8o2BUeXgVOaRACTrcmMAY=; b=qK+TNaAgHzK9YgIWx9vlu1UIBBHNvnsSwM4x02ZyOMBwnh/lZ7A+tJfcnCtUYZYsyl 7z381zOqw8i6OvaDPNP0BsjXWnPGpMFIJmuRv/LoUgN0vXFlZ4fqXo6g0IiJVipx7979 HvVATZal26HLNaXn2WNa4a12eeTmUiFpo0PlmvajY0Z9K074cId89Y2C7hVDkpb/DYVk jSeUKFTF1WI+TReE1/5jlgwEiDuRUJcEFTaADLZF2eLW/B4XLKZhyjdeN+dNvmvwN2Jc JtCzByDHdyCe71aDg+1plEPnrHnCKXg2vnOcgpqhqNdfBfD51eSZ7Z7n0r6OmPmkbABy MMpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736920151; x=1737524951; 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=gqxfn2Bh8pqSgpWAhYuCaH8o2BUeXgVOaRACTrcmMAY=; b=afBASwjOKSg3yK2m6Y/c/g3a54rfIGeReQsl38aLUQ9V4a7T/Yvo1lT1RaNjw4vLOD k+JrUAymYy0SohSvSNopcUsSbgz5t5axjAFw6utmEjfIepYHbtWSYDEgrWj3xpJjE9Il xoTldGw5tNDghaVS7g69Y0dutlfyrtd8qgS28WD0i+aIeVC2tFAnWgJ/X2C0MAHtjvIs p/aAI0eaKK/hM/ODG1eqbNCz8Ea4ySrh8nvsCYIt4YX/AHDgJ41hT2HwQp7cGpHJCIl9 yL9jFEs2EDcTA5jrEpNfFNcSMLX11r9OYx7zdAhMcb2KSegHTFZS88ylPfSRuYPrs233 1KkQ== X-Gm-Message-State: AOJu0Ywfhp1HmaT6PsAraPe/rs+6U6BRshd8ZzaZ5lkiQbc0TCwyp3TB Ig68iwFUgNbmcVuPk0mRsQrZAc7pthwv0ZLrNLnh0bIEcfdZb3cJT1Q3hvK/rhc= X-Gm-Gg: ASbGnctemNW+w3JWh0+W3fxDIAEIPxU4ycFclxMfDj72TDixa98ioBYNmgoOcfutO56 6NrSGQ0ox1qe/4WDWQ7humfjTDj8jfNlyRhmBfHsQQNAtpLK0hbc6GSrqyBIpZqkanz/rdtlQZH kraQo1A3PcMrG2NRH1uoOsBQFZp9W1Y88/PUiiBES5kDWMnoE0ffex+x8MTg5GNparvvsW532z3 CNoQQ+YUz9ofcqfkp4nWSEOe10WpwHxLbVtVmL1fjufku1+JFDIcYg2fSA= X-Google-Smtp-Source: AGHT+IGEE8Fm6k+e43goXL9XR3kNG0Qk7QvIMeGK5viYe25EF4qO0xqHuY9x+AzGWdKmvE+R7dTOXQ== X-Received: by 2002:a05:6a21:1087:b0:1e1:b727:181a with SMTP id adf61e73a8af0-1e88cfd3cb1mr47297876637.24.1736920150754; Tue, 14 Jan 2025 21:49:10 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-72d406a94b8sm8295174b3a.167.2025.01.14.21.49.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jan 2025 21:49:10 -0800 (PST) From: Akihiko Odaki Date: Wed, 15 Jan 2025 14:48:02 +0900 Subject: [PATCH v5 5/6] s390/crash: Use note name macros MIME-Version: 1.0 Message-Id: <20250115-elf-v5-5-0f9e55bbb2fc@daynix.com> References: <20250115-elf-v5-0-0f9e55bbb2fc@daynix.com> In-Reply-To: <20250115-elf-v5-0-0f9e55bbb2fc@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: rspam04 X-Rspamd-Queue-Id: 07BE1A0009 X-Stat-Signature: bqtzwfu34hajcxsxebg8y8dyczba7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nJsVv4TjHvmblMV/VLW2blUQPima1DRtCElnYg/cGlliGlzyAJysCNtdl8c/Azf95uljIzcywgR9b48733iV+McJfG18WyzgeWDWXy6lsHwnluzk+xKD4dx4caOGjI2GdvWc4Va1qgr4Bhzl4Imw2ReJSzLk9/SDhE7/vCCbFKHOOE+i400hUtnH1+lDmspoVyvnq1Sz8fl3bBW5BWuiXfeZwd12Tmx+lMyFaTUGLGaVbk8w6eyr7Kb76gTEeDQ46QlyFAarnvDbIX34kmdKfvdmAXo5LqUasvco4TwCKAFUg2cg5YGAQpoDY2d0zejvTp3O23Dr+1nKe01FaDQpfp06Udc5hW9GaeVL5lGMUc75rhE5GXlocEr4ZE= 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 Reviewed-by: Dave Martin --- 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 */