Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4312672pxb; Tue, 31 Aug 2021 01:55:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSmagy5ptEglI0nrrDeGx8Cw7uEq11xT1V/ypMlQcpja0Xwm+WmcUwN3d1vv5YNdGAcMHd X-Received: by 2002:a6b:f214:: with SMTP id q20mr22219292ioh.84.1630400159144; Tue, 31 Aug 2021 01:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630400159; cv=none; d=google.com; s=arc-20160816; b=aIbzbvi8ZOXgy+LHF/LJu5aW/uz293/5FivDjiGlH6XTGlzOELiO8Qkrzar4HNdNa2 7FVPGXfxBzSgSJYX91nfGv7JFAmk5mqxmtUsXa8va5iXnCwbLgkgF1o9CunP7YNJwKmc T6Ul2savXlgrCijYbIZTV2q3fN0a00zduLaA6eHb6hfXb08b5zFV9nbAd7uKbkHyxo90 EqTjJytABtuR0tb3kj3WLwl46H7+g/pNgTOwqQWqtOcyjobQiEQRstaxWMCYgE0znJnQ 0Q8RoAt7evJpZzq5X+fP4knFV5BV80/tldI3K4j6jB5ej2ooGS/f6VuCQ1ncWeacBiOh A31Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ZmG1a/597i+bVLQ4WDPgynEWM4bM+EsGf7wthbR9ziI=; b=Aq8yJ/3qnPGfXbO5GDEjV10F9UvVPRYBeZeEaE48PVzEdmTzZUTkAf1UyUkILlvDTH 5/Oa9oGE5clap0tGWboM1/P1JP0sPgFIzQ66grBLi/blYttnYwfiDU/w2XZ7XLEz2mfK yLgNDzjKPRAIPCq54eDtGrCMmDvhJxWEsQkGE1YhuvgXGgK7bggJvLJREN7e9263yRwX tA8UIMFXBxHOBBUh8nyF+nNNDjz4ZfYQqmh2VDBGXWN69/oy497Hw5YchNDfys0lyFHu klawa9KJL13W2xobSojiue61uKhe3ZSg/bO58Y9Z8dg9vDOwQ1TxPSZxMpe1/d3zQj1w 15Zg== ARC-Authentication-Results: i=1; mx.google.com; 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 o20si18422247iov.71.2021.08.31.01.55.48; Tue, 31 Aug 2021 01:55:59 -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; 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 S240469AbhHaIzm (ORCPT + 99 others); Tue, 31 Aug 2021 04:55:42 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:59473 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240423AbhHaIzk (ORCPT ); Tue, 31 Aug 2021 04:55:40 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4GzLbm5bJSz9sTZ; Tue, 31 Aug 2021 10:54:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7g6dDEZLufQh; Tue, 31 Aug 2021 10:54:44 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4GzLbm4cx0z9sTX; Tue, 31 Aug 2021 10:54:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8243C8B7DE; Tue, 31 Aug 2021 10:54:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ETEfsJj37GqN; Tue, 31 Aug 2021 10:54:44 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 14BA48B7DD; Tue, 31 Aug 2021 10:54:44 +0200 (CEST) Subject: Re: [PATCH] powerpc/64: Avoid link stack corruption in kexec_wait() To: Daniel Axtens , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <3ffe7775f3fcda8e5fca6a7bc7db0b8251153c67.1629705147.git.christophe.leroy@csgroup.eu> <87ilzm6str.fsf@dja-thinkpad.axtens.net> From: Christophe Leroy Message-ID: <9f43118b-ef81-9a80-0e0b-5e74433e0b8c@csgroup.eu> Date: Tue, 31 Aug 2021 10:54:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <87ilzm6str.fsf@dja-thinkpad.axtens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 31/08/2021 à 08:17, Daniel Axtens a écrit : > Hi Christophe, > >> 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. > > 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 hot path or not ? If it is I use bcl 20,31, if it is not I use bl". The best way to keep things in order is to always use the right instruction. > >> 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_64.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 > > 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 macro is always puzzling. I like macros when they allow you to not repeat again and again the same sequence of several instructions, but here it is a single quite simple instruction which is not worth a macro in my mind. Christophe