Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4639477iob; Sun, 8 May 2022 20:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuDzjwUUyWmSLuByHsHUK2lGY3zyceCBicedZ6BVFAymcJJqbI3SpUx0/1kyqkug3w2aM5 X-Received: by 2002:a17:90b:3506:b0:1dc:72c6:384d with SMTP id ls6-20020a17090b350600b001dc72c6384dmr24074513pjb.137.1652065992134; Sun, 08 May 2022 20:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652065992; cv=none; d=google.com; s=arc-20160816; b=M39mNH4Ui2gGTSrEL2GSKx+aDoPTLVN0qRwrZQdNN1ylMgS4ziFcOLt55OFlqcBTMP lPhLr+CK/nLns1yjD5W4SCVLNibGV3p/WP3JiQgkuiBWlSPJoRSGkyrQHB6B8qH9agD9 S5CgJunOPsRzeLVTvaHeZkfBISXOC/JGNwAiheKGbSux+UZcX0MUsJA5PqUPTytdrZec cG8sVZ+6Q3ePuacgeYMdlgxLqyE8NEykFIEaiZ89QF+7bsUZz9ZK7skKLCZRDDs3OdoM q2EaHXFKrqPof8ypeXL4ow4+5dKaXM0W9VtZtgsxhik9TCPO+j1TC17H+k6e9XQZqknt eVew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=3mutIDwAoMDYppKvXj+Kh3Lz7GBDin/nQObbZDAncxw=; b=xypHEVX1olXzUGA0dhRfJ9/Qps5F1TZUuU/YMPI3iirkKlw804j/EZI8cZkqpAUFms s09g+OmhZjq769NCTVLQ58Ndex8bhxyvUB5kHpZ9CTQAcemsfhOTji6jl8eXdxjaZWij 6LvXvroIvPaNNqDl2RWdjswDhdRuXsSE0HF0m4wAHguHmUryj9uALBskvi+cGk4XeOsJ Zvo11pTdI9/gZ98+1RdHUqyTMLmoXJcVHB6IEL4nbqDhwp2zszSgB12slnFt6J20iDMn 6BpySwRCJYbdEPZqWGiORWBn61mfUoHkL02i1gezyzPNWkeauztc9f3DkGVnv5rVhXtQ Nudw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=L1yeUp3x; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f4-20020a631f04000000b0039daee7ecf1si13183996pgf.318.2022.05.08.20.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:13:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=L1yeUp3x; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F01D09136E; Sun, 8 May 2022 20:11:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353056AbiEFJWi (ORCPT + 99 others); Fri, 6 May 2022 05:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1390401AbiEFJW1 (ORCPT ); Fri, 6 May 2022 05:22:27 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0457633AE; Fri, 6 May 2022 02:18:44 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2467DF17007169; Fri, 6 May 2022 09:17:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=3mutIDwAoMDYppKvXj+Kh3Lz7GBDin/nQObbZDAncxw=; b=L1yeUp3xv84wxceE4LqZbb6r/vCK7SyqM8/NifRc8RG+IWkiJt6J9D4wqtJSSNEB1mFe rA0C6Ltu6Z/5kahIg5rBv24Ga0d2Ti/46VHxLcOX/Q672acGYV7gdgpcqhzXe+LRhzoV ct70vVFfcof8Ka2bO9/tS+nTwTbufy8MZMfyQziuVzR1e17pxHHbsI8BAZtztm6ozGN5 38K3rKtZbuV3ZY2WdeHLjJPaPesIOQqPGqnG0fWZa9oYqX2YOtoGsk962GaDtk5lM3w8 pt1NSaJzZfAf2NiDAWjQUP3kyZ9HGxqaqFv+IKIa1ojcbvOsDFQTeR6egxd1MNe2+33h rg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fvy3btd3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 May 2022 09:17:43 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2468e2Bl013355; Fri, 6 May 2022 09:17:43 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fvy3btd2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 May 2022 09:17:43 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2469D1uF009644; Fri, 6 May 2022 09:17:41 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 3fvg6112ck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 May 2022 09:17:40 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2469HTr830998854 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 6 May 2022 09:17:29 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C18314C046; Fri, 6 May 2022 09:17:36 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 173AB4C040; Fri, 6 May 2022 09:17:36 +0000 (GMT) Received: from tuxmaker.linux.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 6 May 2022 09:17:36 +0000 (GMT) From: Sven Schnelle To: Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org Subject: Re: [PATCH] bug: Use normal relative pointers in 'struct bug_entry' References: Date: Fri, 06 May 2022 11:17:35 +0200 In-Reply-To: (Josh Poimboeuf's message of "Thu, 5 May 2022 18:09:45 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4n8HqNW6ohwXkIgOJyGIpHi0JkINuDC6 X-Proofpoint-ORIG-GUID: S6dXLhewdUPDA_P7LfTbFsG0u0fKL_4S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-06_03,2022-05-05_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1011 suspectscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205060049 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Josh Poimboeuf writes: > With CONFIG_GENERIC_BUG_RELATIVE_POINTERS, the addr/file relative > pointers are calculated weirdly: based on the beginning of the bug_entry > struct address, rather than their respective pointer addresses. > > Make the relative pointers less surprising to both humans and tools by > calculating them the normal way. > > Signed-off-by: Josh Poimboeuf Acked-by: Sven Schnelle # s390 > --- > arch/arm64/include/asm/asm-bug.h | 4 ++-- > arch/powerpc/include/asm/bug.h | 5 +++-- > arch/riscv/include/asm/bug.h | 4 ++-- > arch/s390/include/asm/bug.h | 5 +++-- > arch/x86/include/asm/bug.h | 2 +- > lib/bug.c | 15 +++++++-------- > 6 files changed, 18 insertions(+), 17 deletions(-) > > diff --git a/arch/arm64/include/asm/asm-bug.h b/arch/arm64/include/asm/asm-bug.h > index 03f52f84a4f3..c762038ba400 100644 > --- a/arch/arm64/include/asm/asm-bug.h > +++ b/arch/arm64/include/asm/asm-bug.h > @@ -14,7 +14,7 @@ > 14472: .string file; \ > .popsection; \ > \ > - .long 14472b - 14470b; \ > + .long 14472b - .; \ > .short line; > #else > #define _BUGVERBOSE_LOCATION(file, line) > @@ -25,7 +25,7 @@ > #define __BUG_ENTRY(flags) \ > .pushsection __bug_table,"aw"; \ > .align 2; \ > - 14470: .long 14471f - 14470b; \ > + 14470: .long 14471f - .; \ > _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ > .short flags; \ > .popsection; \ > diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h > index ecbae1832de3..76252576d889 100644 > --- a/arch/powerpc/include/asm/bug.h > +++ b/arch/powerpc/include/asm/bug.h > @@ -13,7 +13,8 @@ > #ifdef CONFIG_DEBUG_BUGVERBOSE > .macro __EMIT_BUG_ENTRY addr,file,line,flags > .section __bug_table,"aw" > -5001: .4byte \addr - 5001b, 5002f - 5001b > +5001: .4byte \addr - . > + .4byte 5002f - . > .short \line, \flags > .org 5001b+BUG_ENTRY_SIZE > .previous > @@ -24,7 +25,7 @@ > #else > .macro __EMIT_BUG_ENTRY addr,file,line,flags > .section __bug_table,"aw" > -5001: .4byte \addr - 5001b > +5001: .4byte \addr - . > .short \flags > .org 5001b+BUG_ENTRY_SIZE > .previous > diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h > index d3804a2f9aad..1aaea81fb141 100644 > --- a/arch/riscv/include/asm/bug.h > +++ b/arch/riscv/include/asm/bug.h > @@ -30,8 +30,8 @@ > typedef u32 bug_insn_t; > > #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS > -#define __BUG_ENTRY_ADDR RISCV_INT " 1b - 2b" > -#define __BUG_ENTRY_FILE RISCV_INT " %0 - 2b" > +#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ." > +#define __BUG_ENTRY_FILE RISCV_INT " %0 - ." > #else > #define __BUG_ENTRY_ADDR RISCV_PTR " 1b" > #define __BUG_ENTRY_FILE RISCV_PTR " %0" > diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h > index 0b25f28351ed..aebe1e22c7be 100644 > --- a/arch/s390/include/asm/bug.h > +++ b/arch/s390/include/asm/bug.h > @@ -15,7 +15,8 @@ > "1: .asciz \""__FILE__"\"\n" \ > ".previous\n" \ > ".section __bug_table,\"awM\",@progbits,%2\n" \ > - "2: .long 0b-2b,1b-2b\n" \ > + "2: .long 0b-.\n" \ > + " .long 1b-.\n" \ > " .short %0,%1\n" \ > " .org 2b+%2\n" \ > ".previous\n" \ > @@ -30,7 +31,7 @@ > asm_inline volatile( \ > "0: mc 0,0\n" \ > ".section __bug_table,\"awM\",@progbits,%1\n" \ > - "1: .long 0b-1b\n" \ > + "1: .long 0b-.\n" \ > " .short %0\n" \ > " .org 1b+%1\n" \ > ".previous\n" \ > diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h > index aaf0cb0db4ae..a3ec87d198ac 100644 > --- a/arch/x86/include/asm/bug.h > +++ b/arch/x86/include/asm/bug.h > @@ -18,7 +18,7 @@ > #ifdef CONFIG_X86_32 > # define __BUG_REL(val) ".long " __stringify(val) > #else > -# define __BUG_REL(val) ".long " __stringify(val) " - 2b" > +# define __BUG_REL(val) ".long " __stringify(val) " - ." > #endif > > #ifdef CONFIG_DEBUG_BUGVERBOSE > diff --git a/lib/bug.c b/lib/bug.c > index 45a0584f6541..c223a2575b72 100644 > --- a/lib/bug.c > +++ b/lib/bug.c > @@ -6,8 +6,7 @@ > > CONFIG_BUG - emit BUG traps. Nothing happens without this. > CONFIG_GENERIC_BUG - enable this code. > - CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit pointers relative to > - the containing struct bug_entry for bug_addr and file. > + CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file > CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG > > CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable > @@ -53,10 +52,10 @@ extern struct bug_entry __start___bug_table[], __stop___bug_table[]; > > static inline unsigned long bug_addr(const struct bug_entry *bug) > { > -#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS > - return bug->bug_addr; > +#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS > + return (unsigned long)&bug->bug_addr_disp + bug->bug_addr_disp; > #else > - return (unsigned long)bug + bug->bug_addr_disp; > + return bug->bug_addr; > #endif > } > > @@ -131,10 +130,10 @@ void bug_get_file_line(struct bug_entry *bug, const char **file, > unsigned int *line) > { > #ifdef CONFIG_DEBUG_BUGVERBOSE > -#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS > - *file = bug->file; > +#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS > + *file = (const char *)&bug->file_disp + bug->file_disp; > #else > - *file = (const char *)bug + bug->file_disp; > + *file = bug->file; > #endif > *line = bug->line; > #else