Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2673475imn; Tue, 2 Aug 2022 11:37:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v3l5fH7c4/nxVIhs4/zqrBXYLYOgxKXv2Fnfc35v38Hdy2gIj+Mj2Q5Vmni1kudS/t+I4/ X-Received: by 2002:a05:6402:5cb:b0:434:eb48:754f with SMTP id n11-20020a05640205cb00b00434eb48754fmr22749353edx.421.1659465425440; Tue, 02 Aug 2022 11:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659465425; cv=none; d=google.com; s=arc-20160816; b=TTrtbjKJFcVUeievT1JKkEbrWpDzVYkwH3GvEPzNZPcQfCwqIyLk/NYnZ3uE2ebQKE c0F8Cec8jattNyMFxIUUcAO0sDz9wKLwUcgXdSArjMscAaSC2xJDNS3vKUdF5YRkGogU t3s5KHpe2ThXdPn5H+55Eq7k5Er3DLCwBIiS+cCZuKJQ6pCIlPlEHa5ZH8Skzh1+xW8f DDBj8NwOOMpGFXr63Io43NeF7e7hSO3j/A+z57GBuxYJI2WMm7A6KLnZAEfJkirtKF6L 0YdDb/ZAd9ASW2tNl70CsgUyZByRjAfmIoyp+yPuzDe4ISiag4PTtlYcC+7oqAuh7vN/ IoPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=TJm/QNzw2I7mTXtxSIe6+MPkHY9hb4kDGVaxsebc8lc=; b=IYxpuKqDkAFUBjVrDSuWWRs61umig4JQ1B6tcf0IekWHfnRMpFao3eUyFgAnJs13W6 l526z2hDmiwqyQ/a6jhsUblKVk8vUVL9kbFPdjwnNRfUx8eIDAxj9sQAljkHlAyej4rM YItwCTpY4m5o5ng15CdZW546xK8I9pjlz2DL5cg/6cWG2r0lW2RzdrwbYnDGFi3OTl4d qp7HRbd5d/0vmlt7NQMn3CE7k9XxuIzJgeNg04egNs1I5I6WCgC96zOBaxzZ5Q9tlsxK OIyOx7xqO9cofPZIYDGaAyQQ7CNnHILlJrCYO4MYBVEix6j1/TRU/0xM1cxq+hcS7cE1 UTLw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv13-20020a17090760cd00b007306d54e110si8715155ejc.746.2022.08.02.11.36.40; Tue, 02 Aug 2022 11:37:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233188AbiHBSRk (ORCPT + 99 others); Tue, 2 Aug 2022 14:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbiHBSRj (ORCPT ); Tue, 2 Aug 2022 14:17:39 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A247E32EFE; Tue, 2 Aug 2022 11:17:38 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 272IDHUg002582; Tue, 2 Aug 2022 13:13:17 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 272IDFmt002581; Tue, 2 Aug 2022 13:13:15 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 2 Aug 2022 13:13:15 -0500 From: Segher Boessenkool To: Christophe Leroy Cc: Michael Ellerman , Nicholas Piggin , Pali =?iso-8859-1?Q?Roh=E1r?= , stable@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/3] powerpc: Fix eh field when calling lwarx on PPC32 Message-ID: <20220802181315.GI25951@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham 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 Hi! On Tue, Aug 02, 2022 at 11:02:36AM +0200, Christophe Leroy wrote: > Commit 9401f4e46cf6 ("powerpc: Use lwarx/ldarx directly instead of > PPC_LWARX/LDARX macros") properly handled the eh field of lwarx > in asm/bitops.h but failed to clear it for PPC32 in > asm/simple_spinlock.h > > So, do as in arch_atomic_try_cmpxchg_lock(), set it to 1 if PPC64 > but set it to 0 if PPC32. For that use IS_ENABLED(CONFIG_PPC64) which > returns 1 when CONFIG_PPC64 is set and 0 otherwise. > > Reported-by: Pali Roh?r Reviewed-by: Segher Boessenkool > + unsigned int eh = IS_ENABLED(CONFIG_PPC64); > > token = LOCK_TOKEN; > __asm__ __volatile__( > -"1: lwarx %0,0,%2,1\n\ > +"1: lwarx %0,0,%2,%3\n\ > cmpwi 0,%0,0\n\ > bne- 2f\n\ > stwcx. %1,0,%2\n\ > @@ -59,7 +60,7 @@ static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock) > PPC_ACQUIRE_BARRIER > "2:" > : "=&r" (tmp) > - : "r" (token), "r" (&lock->slock) > + : "r" (token), "r" (&lock->slock), "i" (eh) > : "cr0", "memory"); That should work yes. But please note that "n" is prefered if a number is required (like here), not some other constant, as allowed by "i". Thanks! Segher