From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6261112CD88 for ; Wed, 8 Jan 2025 04:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736312041; cv=none; b=mH36Q2PzU1ZXezm1R6p5MJJuWJIjriW6IGU4WBmj7s7UYuJRv0ZfD1coTTTbFz5yLSoqAQRO2Dm/wDk6lPMLOVaT8cXmFu+5JBAY2rWtpT1hrEb0RLLVmakiv420UsunKyljwl8PZO4fR8iTOJOQCMA95vF31PGf3RQa4RiX3eA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736312041; c=relaxed/simple; bh=uyuDNtIOBYqDnWryQRHZ5qBgToQ3gandNYmtpBPm+rw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VkenzHyZtXLUbJkiAeysDZiX/T+SRmx9n4eqf5rwqO7Yi2O+/Ci6QWq46QKWSzAfXlXQjT3ruThqW0r/4WUqg2cALv/jI/8glOvLNDJFl+VjfJC4yW0TH26zQ21srZN2MsQeYSkeN2yAEJaMvBTgK2UO/7uK7h7hxE/lWNMTpJA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=pass smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=T9UM9MYn; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="T9UM9MYn" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2eed82ca5b4so23665322a91.2 for ; Tue, 07 Jan 2025 20:54:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736312040; x=1736916840; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=NTAeASi7vVObUDW8V2zM5ksK3/uTU7NPiyOQuEofviY=; b=T9UM9MYnJAYDup3XaXKe6FaHMEqXE6bUv5D1cJocXi0GJsyeArPdMbZHAg0CBAcGxh PuVoL7QmyBFDp22EV21u8R8765Mun1IKil1uYvidEK6q/OwtMrZOp9zICYsTyxZOF9S4 MsERuJ+5AtQQHYKDqAlUJypCmvxgToWiuAJPnC3pCcB05zSUHUq86xg7oak+JLp4XQj5 lw3qyNc+TNMsOjZ0H0l+/tw72ROdlMbxyyeG5HQiN6OfX+sgoFlhCbQZJxstUCFq7vty ebCv3kkuCh2hvHmvbvmDVohkiKIU8lPO9QIWVgjzYLjc7NXtBAqa2B1swWPfpX2UCUfs Sh5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736312040; x=1736916840; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NTAeASi7vVObUDW8V2zM5ksK3/uTU7NPiyOQuEofviY=; b=nUSqwvktd9b9wXK8Lq/svgxz0WBFP0UMZ/YKyR70/uYs8vSLJ8K8BS5IX5b/2mPI1e w0Q2W4v3oqCMEfJr3IpG6LT3Tp3vQ7iml3mRDQeUQoBBtaFFJdnbgMc9zeKmpoAYgz+x gpqcDvDf4M0sP7sPGqfasnY3CWnCzmI4B6fzazkfllrQDb8zGuvylgAhHUnEEAbhMeik tdmFkNg5TYS28+dZWCEAbflDLbkrH73c9aB64e0Aq/LAkwd2Q0J9V7cq1dFy9ZBl/nBF xb4kr1N8VVeiin4y6tGK8SQSsyT57Wab9H3SEqUlXR1TVE9oGgDjyhgjJBTncmbjH6Jj KJ0A== X-Forwarded-Encrypted: i=1; AJvYcCWIj/RjBZ51qmmZw/pybVLiVeMxUHd7e9cCMKdp9fyzESj4UyCq+wt9rKwzXJNTU72w2ngArPHk51rxWHg=@vger.kernel.org X-Gm-Message-State: AOJu0Yyo+uoVYNR+uDkaFN3twGdppZyO+TGBqsqumk9AaQyZ4r+TEgay XrIDx6wiifHtEpDplnM/uVbxXE4TSzlvlQkzExECDPHxIRbwgq6lTl6XyPX/0bc= X-Gm-Gg: ASbGnct3rjSDpUYT6z7PKsVMSTZ4MlT0et/UObt5JbKyuyukWwEyiLUFsyzg7ZWERWr B2UqWqFiuKLAKX89BwtoQR14Yr2skBZcILGag/oIzuleqSZhys8pL7PsT6xA7ItLNxnRZEh+lLy wnwsPkBDbsuFsgC0rGq6dQQoDkMb3azg+7nqP6TRo3Y8FS9F2jkL+vPz503rKdcD6jqmGCNeA+E OOXiuwS9h0CdNNkARXT3c5jlhPjpvtYNYuEkGAl5EtkrygIYoJlOvxpSrJapOH1OO0= X-Google-Smtp-Source: AGHT+IGF/lDnmbVBM65O0BZ//6tKBYkr4Hn46ySNw0SXEM+WKDuSN4ZlNc368YPeAlJVvXi3c8brJg== X-Received: by 2002:a05:6a00:1385:b0:72a:aa0f:c86e with SMTP id d2e1a72fcca58-72d21f17738mr1884512b3a.4.1736312039609; Tue, 07 Jan 2025 20:53:59 -0800 (PST) Received: from [157.82.203.37] ([157.82.203.37]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d012b1de0sm4918303b3a.80.2025.01.07.20.53.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2025 20:53:59 -0800 (PST) Message-ID: <965b73e7-d0a3-4fae-b0ec-70b5497cb6c4@daynix.com> Date: Wed, 8 Jan 2025 13:53:51 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 5/6] s390/crash: Use note name macros To: Dave Martin , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle 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 References: <20250107-elf-v3-0-99cb505b1ab2@daynix.com> <20250107-elf-v3-5-99cb505b1ab2@daynix.com> Content-Language: en-US From: Akihiko Odaki In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025/01/08 1:17, Dave Martin wrote: > 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.) I wanted to clarify it is a macro as it concatenates tokens with ##, but I also find there are many macros that are named lower-case and performs token concatenation. S390 maintainers, please tell usr your opinion. > > (Note also, the outer parentheses and the parentheses around (buf) > appear redundant -- although harmless?) They only make a difference in trivial corner cases and may look needlessly verbose. > >> >> /* >> * 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