Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19106726rwd; Wed, 28 Jun 2023 05:17:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7aFXxjVG3kHVLp6SFh/z37R+3cuN+jq33NmkDn9FRZ30cG4PrS5/UV2+81L2gTV+0ENCWY X-Received: by 2002:a05:6a20:8f0b:b0:107:1805:feea with SMTP id b11-20020a056a208f0b00b001071805feeamr47169036pzk.37.1687954643960; Wed, 28 Jun 2023 05:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687954643; cv=none; d=google.com; s=arc-20160816; b=uRpzDs1QodBxnB+oThUBgZQYSeJnGXQvk1s5uuMnbX2j2sMETNvCp4GgzVlEDR6MGz f8Ji3u4igFkmC3g7Keibr16fNwNvkZIm2tqeqYIVl2sDI685pTxF2OcC5shQuzFz14Gp PRI8B99pp4n13x2XagOUOEDPFULQZPNl9NagYNGhw1W/GPj3xpFGf+FhtGhNuOMoAF00 6NNNrlVR5haR/WMKf0cjDkKujiDbYFxjj0OrnQ7R/zbyIN1bnquE4TgVXIiyS/nQXZOB Zxla8VIFIfdox6AZ66k3++4sYc3DtSGfaGZ5oRy179q0d8BeIehGL59cit1t+T2FzChx GWww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=LfazAWWIwKtXXwtBhF/5RDoxnADVvS9MLDW20NXhRt8=; fh=H7oU2RPhGBlPaZ2coOVaOAzxiD/E4VD+ZOenu54nER0=; b=ZbtbDag/ztFEClNffDIUoNyB7fsPV46gVzuuOV63Msae66U3S+AjRWyotRONFQklxf h/whtJdxy00qIVm3g386xhKxjm0YpO92tBHCMC7rR2kvxDEY20prgmwkhYxg0+9PxCta C6uWRRrQZAOFfKANXvQAdV+NvUtX93/c4HfDw8/smNMfJ7pONdmHP4xPFsUrBghMAuoT PnNPeoQWXKboZCcw4evLoAeaH7P82LJu1/dLbl3wGQ/c6qYacGrZat+/FR3JNbT8oWeS nBtKlTpaJvo9cu3g+20MbftU2j5yjKYFyVhV1m54gq4KPLOEZE2qiHPWVprAeiPA5omq 4fWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l70-20020a638849000000b0054fdfd26dffsi9308170pgd.337.2023.06.28.05.17.11; Wed, 28 Jun 2023 05:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjF1Lpu (ORCPT + 99 others); Wed, 28 Jun 2023 07:45:50 -0400 Received: from foss.arm.com ([217.140.110.172]:54160 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjF1Lpt (ORCPT ); Wed, 28 Jun 2023 07:45:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 493B3C14; Wed, 28 Jun 2023 04:46:32 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.29.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D8063F663; Wed, 28 Jun 2023 04:45:46 -0700 (PDT) Date: Wed, 28 Jun 2023 12:45:43 +0100 From: Mark Rutland To: Arnd Bergmann Cc: "David S. Miller" , Kees Cook , "Peter Zijlstra (Intel)" , Arnd Bergmann , Guenter Roeck , Geert Uytterhoeven , Ingo Molnar , Andi Shyti , Andrzej Hajda , Palmer Dabbelt , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sparc: mark __arch_xchg() as __always_inline Message-ID: References: <20230628094938.2318171-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230628094938.2318171-1-arnd@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 28, 2023 at 11:49:18AM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann > > An otherwise correct change to the atomic operations uncovered an > existing bug in the sparc __arch_xchg() function, which is calls > __xchg_called_with_bad_pointer() when its arguments are unknown at > compile time: > > ERROR: modpost: "__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined! > > This now happens because gcc determines that it's better to not inline the > function. Avoid this by just marking the function as __always_inline > to force the compiler to do the right thing here. > > Reported-by: Guenter Roeck > Link: https://lore.kernel.org/all/c525adc9-6623-4660-8718-e0c9311563b8@roeck-us.net/ > Fixes: d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional") > Signed-off-by: Arnd Bergmann Aha; you saved me writing a patch! :) We should probably do likewise for all the other bits like __cmpxchg(), but either way: Acked-by: Mark Rutland Mark. > --- > arch/sparc/include/asm/cmpxchg_32.h | 2 +- > arch/sparc/include/asm/cmpxchg_64.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h > index 7a1339533d1d7..d0af82c240b73 100644 > --- a/arch/sparc/include/asm/cmpxchg_32.h > +++ b/arch/sparc/include/asm/cmpxchg_32.h > @@ -15,7 +15,7 @@ > unsigned long __xchg_u32(volatile u32 *m, u32 new); > void __xchg_called_with_bad_pointer(void); > > -static inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) > +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) > { > switch (size) { > case 4: > diff --git a/arch/sparc/include/asm/cmpxchg_64.h b/arch/sparc/include/asm/cmpxchg_64.h > index 66cd61dde9ec1..3de25262c4118 100644 > --- a/arch/sparc/include/asm/cmpxchg_64.h > +++ b/arch/sparc/include/asm/cmpxchg_64.h > @@ -87,7 +87,7 @@ xchg16(__volatile__ unsigned short *m, unsigned short val) > return (load32 & mask) >> bit_shift; > } > > -static inline unsigned long > +static __always_inline unsigned long > __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) > { > switch (size) { > -- > 2.39.2 >