Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4454401pxb; Tue, 31 Aug 2021 05:44:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzbjJos80KCPws/h6Cpr1y0y7aSaoO2/Y8swYrzzVSf48BV3mCVkHgpRfTmC25KUR8NJEi X-Received: by 2002:a6b:5c17:: with SMTP id z23mr21441591ioh.3.1630413879960; Tue, 31 Aug 2021 05:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630413879; cv=none; d=google.com; s=arc-20160816; b=RvJjMHK7DuBxO03xwfaF20UGdU1JRhSZj/XwqvYVkpILEp5rWbcYZD252GzN4y/rP2 nMZpbo7NFfFyfGIa95FSmdU1Z4JbN2r/h/p+v6ov5o0dkDPy98AAKEndKHpMzJdJ4hwS j4U1kRbzkbchDHYIURR70DzE7hIfy379X2YtHYyJrh2j3U9r1ju/sQ7rB3nS0E1ysqoD tb+vIiCQLsmL6zaaaVokfxE5EaP1KhUmQhQlm7o0l9r8rwoQ83Iu/dEc4qz2iiHhH3uX TyvistfSnvAvA7LWK38IxFO+B/px9wLCrkMjiaZB52CHgN8tfJMv5UPrSHkN1wAMIOQA h+ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=1T9uonz6ZV23kuXHurfGRVVB5lj7jIMJH16i3NUSCRI=; b=TijTN5Jf3rLLlLG1qD13lGswtz12goQguvl+Pn4FCJxIwUxKR/UR8+xiNucmdoGUTF R3AWDCPTgQ4Wo4gf3oe28peFk4+0CwMTxiW2xh/buBzHRY1HIX9NrefJXFqbduwM3jSI p0sTjT+Fc6hpuhVFexgVA5k8QCBL1LOiUUyJO6h3e1GcWPFqYT7marCN4h+aYWCHYR0I dgHTfVO2Kl33N0AsKuA3cCaonYrMZ8rntJouQXwCvLeM3Qo5Ty245CJx/pDmSDr4FzdQ drsBJ1fXEsp3lgoYhMC7zpAmtl67tLUI6+wU9j/I1jTyUqwBCL9QFw7bd9mrUWBsI79y vO/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=nfZ6GVy6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si12107525ilv.93.2021.08.31.05.44.27; Tue, 31 Aug 2021 05:44:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=nfZ6GVy6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232332AbhHaMoE (ORCPT + 99 others); Tue, 31 Aug 2021 08:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231917AbhHaMoD (ORCPT ); Tue, 31 Aug 2021 08:44:03 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3781CC06175F for ; Tue, 31 Aug 2021 05:43:08 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id u1so6751214plq.5 for ; Tue, 31 Aug 2021 05:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=1T9uonz6ZV23kuXHurfGRVVB5lj7jIMJH16i3NUSCRI=; b=nfZ6GVy6XIZpVYmM2uOlyVC1X/U0qS3IIyNg9Nzojxlxxo1q4qjqwJkv99OFwFFelU /TI02CsSbxj5tiUl8aw/d+B2sy7z/krc9mKngFTEwZ6nuyaf9z3dT9Dt4efJcgshuF27 /tFGNWA7GjwDT+fPl83WNTH1BxiKsufoewBTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=1T9uonz6ZV23kuXHurfGRVVB5lj7jIMJH16i3NUSCRI=; b=jVP0IaWSlSjg1c8ft3UFvZqMipydDPlsxkhRwwvNMHA8vdd7ey0L7izkI3HXfT455n nnZHMEpQYYz4UvJEmEP/4bibm8t86mj9tidofQHiEhevdHrOxx/hGaSBuXTMN3rrGV9H 1iitVbAu5fOsAMyFt5BSkitvllQG7vES0muAgjNyfW989A3mQBQ+lzZt6BHkM/pC+zi9 hc4uVkSnzGFoyAddWP6V7OtEJAA9YJZvRt/FGXJ2GCrFsBDVNPfXe1LraUfG4UmK0+d5 XA6KlBJp2kh642b2V5Gv72+2iDPpV6z6KKpLbiKoX67sZV6085Qu9ZweWgS7nypqA0vw g4fg== X-Gm-Message-State: AOAM530eYQorF189eXwZXouBtXApTw38Lo0kHUTqn7wNOU+/MiGp62po N0BANtHaun1V55o8zN+bDkECBzBZGGa1gw== X-Received: by 2002:a17:902:7c93:b029:12c:b603:150d with SMTP id y19-20020a1709027c93b029012cb603150dmr4544469pll.5.1630413787686; Tue, 31 Aug 2021 05:43:07 -0700 (PDT) Received: from localhost ([2001:4479:e200:df00:a664:ffe7:ee94:4600]) by smtp.gmail.com with ESMTPSA id t38sm17484590pfg.207.2021.08.31.05.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 05:43:07 -0700 (PDT) From: Daniel Axtens To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc/64: Avoid link stack corruption in kexec_wait() In-Reply-To: <9f43118b-ef81-9a80-0e0b-5e74433e0b8c@csgroup.eu> References: <3ffe7775f3fcda8e5fca6a7bc7db0b8251153c67.1629705147.git.christophe.leroy@csgroup.eu> <87ilzm6str.fsf@dja-thinkpad.axtens.net> <9f43118b-ef81-9a80-0e0b-5e74433e0b8c@csgroup.eu> Date: Tue, 31 Aug 2021 22:43:04 +1000 Message-ID: <87fsup7pk7.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy writes: > Le 31/08/2021 =C3=A0 08:17, Daniel Axtens a =C3=A9crit=C2=A0: >> Hi Christophe, >>=20 >>> Use bcl 20,31,+4 instead of bl in order to preserve link stack. >>> >>> See commit c974809a26a1 ("powerpc/vdso: Avoid link stack corruption >>> in __get_datapage()") for details. >>=20 >> From my understanding of that commit message, the change helps to keep >> the link stack correctly balanced which is helpful for performance, >> rather than for correctness. If I understand correctly, kexec_wait is >> not in a hot path - rather it is where CPUs spin while waiting for >> kexec. Is there any benefit in using the more complicated opcode in this >> situation? > > AFAICS the main benefit is to keep things consistent over the kernel and = not have to wonder "is it a=20 > hot path or not ? If it is I use bcl 20,31, if it is not I use bl". The b= est way to keep things in=20 > order is to always use the right instruction. Yeah, Nick Piggin convinced me of this offline as well. > >>=20 >>> Signed-off-by: Christophe Leroy >>> --- >>> arch/powerpc/kernel/misc_64.S | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_6= 4.S >>> index 4b761a18a74d..613509907166 100644 >>> --- a/arch/powerpc/kernel/misc_64.S >>> +++ b/arch/powerpc/kernel/misc_64.S >>> @@ -255,7 +255,7 @@ _GLOBAL(scom970_write) >>> * Physical (hardware) cpu id should be in r3. >>> */ >>> _GLOBAL(kexec_wait) >>> - bl 1f >>> + bcl 20,31,1f >>> 1: mflr r5 >>=20 >> Would it be better to create a macro of some sort to wrap this unusual >> special form so that the meaning is more clear? > > Not sure, I think people working with assembly will easily recognise that= form whereas an obscure=20 > macro is always puzzling. > > I like macros when they allow you to not repeat again and again the same = sequence of several=20 > instructions, but here it is a single quite simple instruction which is n= ot worth a macro in my mind. > Sure - I was mostly thinking specifically of the bcl; mflr situation but I agree that for the single instruction it's not needed. In short, I am convinced, and so: Reviewed-by: Daniel Axtens Kind regards, Daniel > Christophe